Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS Border Property

Tags:

html

css

I have added a border to a button on mouse hover but this disturbs the HTML layout. How can I do this without disturbing the HTML layout?

like image 524
user478636 Avatar asked Sep 19 '26 06:09

user478636


2 Answers

Why not have a border there all the time, but initially have it the same colour as the background so it's effectively transparent?

Then simply change the colour on mouseover.

like image 157
Sir Crispalot Avatar answered Sep 24 '26 18:09

Sir Crispalot


You can use css box-sizing property write like this:

.child:hover{
    border:1px solid green;
    -moz-box-sizing:border-box;
    -webkit-box-sizing:border-box;
    box-sizing:border-box;
}

Check this http://jsfiddle.net/zFJHV/1/

or

you can use

div{
 border-bottom:1px solid red;
 margin-bottom:-1px;
}

EDIT:

may be you can use outline instead of border check this:

http://jsfiddle.net/zFJHV/2/

like image 42
sandeep Avatar answered Sep 24 '26 17:09

sandeep