Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Peter Crawford
2,896 PointsWhy peg the icon css to the anchor element as opposed to the list element?
Why wouldn't the following css serve as well as that which Nick uses in the video? Perhaps it has to do with adding responsiveness in the desktop layout....?
.contact-info li {
display: block;
min-height: 20px;
background-repeat: no-repeat;
background-size: 20px 20px;
padding: 0 0 0 30px;
margin: 0 0 10px;
}
.contact-info li.phone {
background-image: url('../img/phone.png') ;
}
.contact-info li.mail {
background-image: url('../img/mail.png') ;
}
.contact-info li.twitter {
background-image: url('../img/twitter.png') ;
}
Here's the relevant html:
<ul class="contact-info">
<li class="phone"><a href="tel:1234567">1234567</a></li>
<li class="mail"><a href="mailto:me@example.com">me@example.com</a></li>
<li class="twitter"><a href="http://twitter.com/intent/tweet?screen_name=example">example</a></li>
</ul>
And here's Nick's css from the video:
.contact-info a {
display: block;
min-height: 20px;
background-repeat: no-repeat;
background-size: 20px 20px;
padding: 0 0 0 30px;
margin: 0 0 10px;
}
.contact-info li.phone a {
background-image: url('../img/phone.png') ;
}
.contact-info li.mail a {
background-image: url('../img/mail.png') ;
}
.contact-info li.twitter a {
background-image: url('../img/twitter.png') ;
}
1 Answer
Joey Bruijns
Full Stack JavaScript Techdegree Graduate 47,878 PointsI think he does it because that way you can use the icons as a clickable link also.
If you don’t do it like that the icons are still there but you can’t click on them.
Peter Crawford
2,896 PointsPeter Crawford
2,896 PointsGood point - thanks!