Reputation: 128
I have two divs and why those divs are moving while hovering?
HTML
<div class="two">
<label class="one">
<input type="radio"> Sanjeev
</label>
</div>
<div class="two">
<label class="one">
<input type="radio"> Hari
</label>
</div>
CSS
.one{
border:1px solid red;
display:block;
opacity:0.5;
}
.two{
margin-bottom:5px;
}
.two:hover{
border:1px solid red;
}
Upvotes: 1
Views: 583
Reputation: 6894
This is happening because on hover you're adding a border which is changing the dimensions of the div.
You can fix this by setting a transparent border before the hover.
.one{
border:1px solid red;
display:block;
opacity:0.5;
}
.two{
margin-bottom:5px;
border: 1px solid transparent;
}
.two:hover{
border:1px solid red;
}
<div class="two">
<label class="one">
<input type="radio"> Sanjeev
</label>
</div>
<div class="two">
<label class="one">
<input type="radio"> Hari
</label>
</div>
Upvotes: 1
Reputation: 6694
You can solve this by assign a border transparency
.two {
border:1px solid transparent;
}
Upvotes: 0