Skip to content Skip to sidebar Skip to footer

Css Hover Border Without Re Sizing Image

I would like to ask what have I done wrong on my hover border-below function without re sizing the image? I have followed the guide given here under inner border but still my link

Solution 1:

You have a constraint on the total height of the container for the anchor containing the image. When you add the border you are adding 5px to the height of the container, which will shrink the image since it is maintaining its aspect ratio to fill the smaller available height. Since margins are not considered when calculating the size of the container it is changing size. I changed it to change the size of the padding instead here.

.navbar-diva:hover { 
  border-bottom: 5px solid black; 
  padding-bottom: 5px; 
}

You may consider trying a different, less complicated approach. Since you will always know your background color you could make the border invisible but always there by just changing the color as seen here.

Solution 2:

You can use :after pseudo-element. Code:

.navbar-diva:hover:after {
    content:"\a0";
    display:block;
    padding:2px0;
    line-height:1px;
    border-bottom:2px solid #000; 
}

http://jsfiddle.net/w4zvad1x/

Solution 3:

You must change the

.navbar-diva:hoverimg { 
  margin: -5px; 
}

What it is doing is to shrink the space inside the DIV, so the image will shrink also.

Post a Comment for "Css Hover Border Without Re Sizing Image"