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

CSS

How to get a border top to be 100% of VW above an a tag?

Hello, I would like to make a border top for my a tag nav links in a mobile screen size. however I can only get it to cover the length of the a tag. Any ideas on how to do this?

css

.nav li a {
    text-decoration: none;
    color: black; 
    font-size: 1.8em;  
  border-top: 1px solid darkgrey;  
}
            <div id="menu">
                    <ul class="nav">
                        <li class="selected"><a id="main.html">Home</a></li>
                        <li><a href="about.html">About</a></li>
                        <li><a href="contact.html">Contact</a></li>
                        <li><a href="testimonials.html">Testimonials</a></li>
                    </ul>   
              </div><!--closing id menu div-->

2 Answers

Hi Tracy,

I think what you're asking is how to get your anchor tag to 100% wide, which will make the border-top 100% wide.

Please clarify if this is not what you want.

body {
  margin:0;
  padding:0;
}
.nav {
  margin:0;
  padding:0;
  list-style:none;
}

.nav li a {
  display:block;
  padding:5px 10px;
  text-decoration: none;
  color: black; 
  font-size: 1.8em;  
  border-top: 1px solid darkgrey;
}

.nav li a:hover, .nav li a:focus {
  background-color:#EEE;
}
<!-- No change -->
<div id="menu">
  <ul class="nav">
    <li class="selected"><a id="main.html">Home</a></li>
    <li><a href="about.html">About</a></li>
    <li><a href="contact.html">Contact</a></li>
    <li><a href="testimonials.html">Testimonials</a></li>
  </ul>   
</div><!--closing id menu div-->

Thank you :) that worked?

Cool, glad it helped.