In the following code, I set the lower border of ul . When hovering over elements in ul I want to show the bottom border or hover element exactly on the ul border. I canβt set the position of both borders ( ul and ul ) so that they cross over on hover.
I tried using the absolute position and line height, but could not achieve much success.
Here is how I would like:

Here is the code:
HTML:
<div class="box"> <ul> <li><a href="#">test 1</a></li> <li><a href="#">test 2</a></li> </ul> </div>
CSS
ul{ list-style: none; padding: 0 0 10px; margin: 0; border-bottom: 5px solid green; overflow: hidden; } ul li{ float: left; margin-left: 20px; } a{ text-decoration: none; display: block; } a:hover{ border-bottom: 5px solid red; }
Demo: http://jsfiddle.net/nNvfy/
html css
user3761459
source share