I have following html and css code in which I want <a> tag to wrap around <li> tags using css.
here is jsfiddle
html
<section class="row header">
<ul class="nav">
<li class="navfirst"><a href="#">Contact</a></li>
<li><a href="#">Home</a></li>
<li><a href="#">Resume</a></li>
<li><a href="#">Interests</a></li>
<li><a href="#">Work</a></li>
<li class="navlast"><a href="#">Comments</a></li>
</ul>
</section>
css
.header .nav {
margin: 0;
padding: 0; }
.header .nav li {
list-style-type: none;
display: inline-block;
padding: 0.5% 1%;
border: 1px solid green; }
.header .nav li.navfirst {
margin-right: 4%; }
.header .nav li.navlast {
margin-left: 4%; }
.header .nav li a {
display: block;
text-decoration: none;
border: 1px solid red;
width: 100%;
height: 100%; }
here is scss. above css is converted from scss file
.nav {
margin: 0;
padding: 0;
li {
list-style-type: none;
display: inline-block;
padding: 0.5% 1%;
border: 1px solid green;
&.navfirst {
margin-right: 4%;
}
&.navlast {
margin-left: 4%;
}
a {
display: block;
text-decoration: none;
border: 1px solid red;
width: 100%;
height: 100%;
}
}
}
Remove the padding from the
litags:http://jsfiddle.net/qrXWQ/1/
Add padding to the
a:Remove the
width: 100%andheight: 100%from the rule above, otherwise the padding will mess up the layout…http://jsfiddle.net/qrXWQ/2/
In the rule above the percent unit will not work because it has no base width/height to apply the % to. You have 3 options: 1) leave the padding in the LI, 2) put the padding in the
awith a unit other than % (emfits well here), or 3) use media queries to set a diferent padding for each screen size.