tags:

views:

32

answers:

4

Hi ,

I am adding a div border on the mouseover of the div, but its pushing other divs out of the box.

I have fixed height and width and have 4 divs for row. finally there are two rows with 8 divs and with fixed height. When i mouseover any div , it pushes all the divs below it outside the main box.

I tried to increase the height of the main box , but still it pushes out. can anyone help me with this issue.

+1  A: 

Border gets added to the width, so it is making the moused-over element get larger.. this pushes the other divs around..

It is normal behaviour..

You could use outline instead of border but it IE has limited support (IE8 and above) ..

Gaby
A: 

Set the boxes inside the main div to have an absolute position with top/left values.

box1{
    position: absolute;
    left: 5px;
    top: 5px;
}

box2{
    position: absolute;
    left: 5px;
    top: 55px;
}

. . .

Chris Vuletich
+1  A: 

Border is added to the width of the element. You can try having a border by default with transparent color (or a color that fits with your design), and on mouseover only change the color of the border. Of course you have to subtract the border-width from your fixed height and width.

bazmegakapa
Thankks a lot , this site is amazing.
gov
+1  A: 

Add transparent border to all div elements. Then in your hover event modify border color/type. That will make divs stay in their position.

cps7
Thanks that worked out.
gov