Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Outline border bottom only [duplicate]

Tags:

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;
}
like image 721
Jeanjean Avatar asked May 13 '14 08:05

Jeanjean


People also ask

How do you outline a bottom in CSS?

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.

Can we have two borders in CSS?

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.


2 Answers

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

like image 52
Ruddy Avatar answered Sep 24 '22 07:09

Ruddy


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;

}
like image 36
valerio0999 Avatar answered Sep 23 '22 07:09

valerio0999