I'd like to create a bottom outline border when the cursor is over an image and I don't know how to do this. I'd like to use this kind of inner border because I don't want to have layout problems with a traditional border-bottom.
Here's my current code,with outline margins everywhere:
.img-lightbox-small{
width:110px;
height:110px;
margin: 1px;}
a img.img-lightbox-small:hover{
opacity:1;
outline: 3px solid #4bb6f5;
outline-offset: -3px;
}
To get around the problem you can use border-bottom , with it set margin-bottom: -1px (the size of the border). This will stop it from moving the content below.
Multiple borders in CSS can be done by box-shadow property. Generally, we can get a single border with border property. Box-shadow property is not for multiple borders, but still, we are creating multiple borders with box-shadow property.
To get around the problem you can use border-bottom
, with it set margin-bottom: -1px
(the size of the border). This will stop it from moving the content below.
HTML:
<div></div>
test
CSS:
div {
width: 100px;
height: 100px;
background: #eee;
}
div:hover {
width: 100px;
height: 100px;
background: #eee;
border-bottom: 1px solid;
margin-bottom: -1px;
}
DEMO HERE
outline
is not like the border property. you have all sides, or none.
you'd better use the border property mixed with box-sizing:border-box
which overwrites the box-model, so that your layout doesnt "move".
http://jsfiddle.net/8XjM5/1/
div {
width: 100px;
height: 100px;
background: #eee;
box-sizing:border-box;
-webkit-box-sizing:border-box;
}
div:hover {
width: 100px;
height: 100px;
background: #eee;
border-bottom: 1px solid;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With