In this media query example, if the viewport's width is between 500 to 800 pixels, an email icon will be applied to each email link:
HTML file: | Displayed by browser: |
---|---|
<style>
ul { list-style-type: none; } ul li a { color: green; text-decoration: none; padding: 3px; display: block; } @media screen and (max-width: 800px) and (min-width: 500px) { ul li a { padding-left: 30px; background: url(../html_beg/images/email.png) left center no-repeat; } } </style> <body> <h1>Resize the browser window to see the effect!</h1> <ul> <li><a data-email="[email protected]" href="mailto:[email protected]">John Doe</a></li> <li><a data-email="[email protected]" href="mailto:[email protected]">Mary Moe</a></li> <li><a data-email="[email protected]" href="mailto:[email protected]">Amanda Panda</a></li> </ul> </body> |
Resize the browser window to see the effect! |