WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

CSS3 Media Queries - Examples


CSS3 Media Queries - More Examples

Let us take a gander at some more instances of utilizing media queries.

We will begin with a rundown of names which work as email joins. The HTML is:

Example 1

<!DOCTYPE html>
<html>
<head>
<style>
ul {
    list-style-type: none;
}

ul li a {
    shading: green;
    content adornment: none;
    cushioning: 3px;
    show: block;
}
</style>
</head>
<body>

<ul>
  <li><a information email="johndoe@example.com" href="mailto:johndoe@example.com">John Doe</a></li>
  <li><a information email="marymoe@example.com" href="mailto:marymoe@example.com">Mary Moe</a></li>
  <li><a information email="amandapanda@example.com" href="mailto:amandapanda@example.com">Amanda Panda</a></li>
</ul>

</body>
</html>
Try it yourself »

Notice the data-email quality. In HTML5, we can utilize qualities prefixed with data- to store data. We will utilize the information quality later.


Width from 520 to 699px - Apply an email symbol to each link

When the program's width is somewhere in the range of 520 and 699px, we will apply an email symbol to each email link:

Example 2

@media screen and (max-width: 699px) and (min-width: 520px) {
    ul li a {
        cushioning left: 30px;
        foundation: url(email-icon.png) left focus no-repeat;
    }
}
Try it yourself »

Width from 700 to 1000px - Preface the connections with a text

When the program's width is between from 700 to 1000px, we will prelude each email interface with the content "Email: ":

Example 3

@media screen and (max-width: 1000px) and (min-width: 700px) {
    ul li a:before {
        content: "Email: ";
        textual style: italic;
        shading: #666666;
    }
}
Try it yourself »

Width above 1001px - Apply email address to links

When the program's width is above 1001px, we will annex the email address to the links.

We will utilize the estimation of the data- ascribe to include the email address after the individual's name:

Example 4

@media screen and (min-width: 1001px) {
    ul li a:after {
        content: " (" attr(data-email) ")";
        text dimension: 12px;
        text style: italic;
        shading: #666666;
    }
}
Try it yourself »

Width above 1151px - Add symbol as we utilized before

For program widths above 1151px, we will again include the symbol as we utilized before.

Here, we don't need to compose an extra media question square, we can simply annex an extra media inquiry to our as of now existing one utilizing a comma (this will carry on like an OR operator):

Example 5

@media screen and (max-width: 699px) and (min-width: 520px), (min-width: 1151px) {
    ul li a {
        cushioning left: 30px;
        foundation: url(email-icon.png) left focus no-repeat;
    }
}
Try it yourself »