CSS3 Media Queries - Sidebar Links

This example puts the list of email links into the left sidebar of a webpage:

HTML file: Displayed by browser:
<style>
ul {
    list-style-type: none;
}
ul li a {
    color: green;
    text-decoration: none;
    padding: 3px;
    display: block;
}
#nav {
    width: 35%;
    float:left;
}
@media screen and (max-width: 699px) and (min-width: 500px), (min-width: 1200px) {
    #nav li a {
       padding-left: 30px;
       background: url(../html_beg/images/email.png) left center no-repeat;
    }
}
@media screen and (max-width: 900px) and (min-width: 700px) {
    #nav li a:before {
       content: "Email: ";
       font-style: italic;
       color: #666666;
    }
}
@media screen and (min-width: 901px) {
    #nav 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 id="nav">
  <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!

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.





Congratulations

Back button Table of Contents