html - Border-bottom issue (expanding downwards on hover) -


i'm working on navigation, , can't seem figure out how make bottom border increase in size upwards, instead of expanding downwards (which in turn extends header few pixels), fix extending header setting height, the border still extend downwards instead of upwards.

the css:

header {   margin: 0;   padding: 0;   left: 0;   top: 0;   width: 100%;   position: absolute;   background: #000000; } ul {   list-style-type: none;   display: block;   margin: 0 0 0 20px;   padding: 0; } ul li {   display: inline-block;   padding: 0; } ul li a{   display: block;   border-bottom: 1px solid #fff;   font-size: 19px; } ul li a:hover{   border-bottom: 2px solid #fff;   background: #333;   font-size: 19px; } 

the html:

<header>   <ul id="nav">     <li><a href="">link 1</a></li>     <li><a href="">link 2</a></li>     <li><a href="">link 3</a></li>   </ul> </header> 

the jsfiddle:

http://jsfiddle.net/artsen/ezwvf/

so want increase border-bottom top, right?

i've had website recently. there no other way set specific padding, , border properties.

i edited jsfiddle here: http://jsfiddle.net/ezwvf/2/ (changed properties make test case more visible)

the principle is: swap pixel values padding-bottom , border-bottom on hover. these key lines solution:

ul li {  border-bottom: 1px solid white;  padding-bottom: 5px; } ul li a:hover {  border-bottom: 5px solid white;  padding-bottom: 1px; } 

note: works if don't add css-transition. if unquote css-transition put in fiddle, you'll see div still expands bottom. if want ss-transition you'll need add separate div li's mimic border.


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -