Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adjust the position of border

Tags:

html

css

I have a bottom border of a ul. There's bottom border of links inside the list items also. I want to adjust the position of the link border so that it is exactly on the ul border, so that it looks like this:

enter image description here

I am unable to set the border position. Here's my code:

HTML:

<ul>
    <li><a href="#" class="active">item 1</a></li>
    <li><a href="#">item 2</a></li>
    <li><a href="#">item 3</a></li>
</ul>

CSS:

    ul{
    margin: 0;
    padding: 0;       
    list-style: none;
    overflow: hidden;
    margin-bottom: 5px;
    padding-bottom: 5px;
    border-bottom: 1px solid green; 
}

ul li{
    float: left;   
    margin-right: 10px;
}

ul li a{
    text-decoration: none;
    display: block;
}

ul li a.active{
    border-bottom: 5px solid red;    
}

JSFiddle: http://jsfiddle.net/sZ8Gu/

like image 812
user1251698 Avatar asked Dec 08 '25 10:12

user1251698


1 Answers

Don't know if this will be option for you, but removing overflow and giving height to ul does the job. jsfiddle

like image 199
Morpheus Avatar answered Dec 10 '25 01:12

Morpheus