nitan nitan - 7 months ago 12
HTML Question

Hover moving other elements to the right

Whenever my mouse hovers to one of the long

<li>
elements the other elements move to the right.

Here's the fiddle link :



.footer_links{
margin-top:60px;

}

footer .ourServices{

display: inline-block;
float:left;
margin: 0px -10px 0px 77px;

}

footer .ourServices ul li,a,h3{
text-decoration: none;
color:white;
list-style: none;
}

footer .ourServices .columns_title{
text-transform: uppercase
}


footer .ourServices .columns_title{
margin-bottom:17px;
font-size:23px;
font-family:raleway-regular;
font-weight:lighter;
}
footer .ourServices ul li, h3{
margin-bottom:8px;
font-size:12px;
}

footer .ourServices ul li{
margin-top: 10px;
}

footer ul li:hover{
font-family: 'Open Sans';
font-weight:bold;

}

<div class="footer_links">
<div class="ourServices">
<h3 class="columns_title">Connect</h3>
<ul>
<li>1234 Street Name</li>
<li>Suburb Title</li>
<li>State, Australia 400</li>
<li>Phone:(00) 000 000 000</li>
<li>fax:(00) 000 000 000</li>
<li>info@email.com</li>
</ul>
</div>

<div class="ourServices">
<h3 class="columns_title">Our Services</h3>
<ul>
<li><a href="#">Cotmprehensive geriatric assessment</a></li>
<li><a href="#">Falls, mobility problems</a></li>
<li><a href="#">Incontinence</a></li>
<li><a href="#">Polypharmacy</a></li>
<li><a href="#">Osteoporosis</a></li>
<li><a href="#">Frailty</a></li>
</ul>
</div>

<div class="ourServices">
<h3 class="columns_title">Explore</h3>
<ul>
<li><a href="#">Our Doctors</a></li>
<li><a href="#">Treatments</a></li>
<li><a href="#">Appointments</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>





jsfiddle.net/#&togetherjs=kdkeI5Hnq6

Answer

It is because the width of each div is being determined by the width of its contents, and the positioning of the other div is determined by the positioning of the div beside it. The bold hover effect is causing the text within to get wider, which is causing a chain reaction in the positioning of the other elements.

To fix it, set the width of the container so that it won't resize based on its contents:

footer .ourServices {
    width: 170px;
}