We will use four styles with this example:
Viewport is less than 750 pixels - a list of email links,We will use the value of the data- attribute to add the email address after the person's name:
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: 899px) and (min-width: 750px) { ul li a { padding-left: 30px; background: url(../html_beg/images/email.png) left center no-repeat; } } @media screen and (max-width: 1100px) and (min-width: 900px) { ul li a:before { content: "Email: "; font-style: italic; color: #666666; } } @media screen and (min-width: 1101px) { ul li a:after { content: " (" attr(data-email) ")"; font-size: 12px; font-style: italic; color: #666666; } } </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! |