CSS3 Media Queries - More Examples
Let us look at some more examples of using media queries.
We will start with a list of names which function as email links. The HTML is:
Notice the data-email attribute. In HTML5, we can use attributes prefixed with data- to store information. We will use the data- attribute later.
Width from 520 to 699px - Apply an email icon to each link
When the browser's width is between 520 and 699px, we will apply an email icon to each email link:
Width from 700 to 1000px - Preface the links with a text
When the browser's width is between from 700 to 1000px, we will preface each email link with the text "Email: ":
Width above 1001px - Apply email address to links
When the browser's width is above 1001px, we will append the email address to the links.
We will use the value of the data- attribute to add the email address after the person's name:
Width above 1151px - Add icon as we used before
For browser widths above 1151px, we will again add the icon as we used before.
Here, we do not have to write an additional media query block, we can just append an additional media query to our already existing one using a comma (this will behave like an OR operator):