I'm trying to do a button menu for my web site and I have an issue with the position of the image on mouse hover. This is what I have created so far http://jsfiddle.net/tNLUx/
On mouseover, I want the selected image to grow and the other ones keep their same position just like the first image... how do I make the down images to grow and move down instead of moving up?
#btnSocial {
width:100px;
position: relative;
opacity: 0.5;
-webkit-opacity: 0.5;
-moz-opacity: 0.5;
transition: 0.5s ease;
-webkit-transition: 0.5s ease;
-moz-transition: 0.5s ease;
}
#btnSocial:hover{
width: 150px;
opacity: 1;
-webkit-opacity: 1;
-moz-opacity: 1;
}
<img src="http://img24.imageshack.us/img24/3221/32845401.png" alt="img1" id="btnSocial" class="social1" />
<img src="http://img24.imageshack.us/img24/3221/32845401.png" alt="img1" id="btnSocial" class="social2"/>
<img src="http://img24.imageshack.us/img24/3221/32845401.png" alt="img1" id="btnSocial" class="social3"/>
<img src="http://img24.imageshack.us/img24/3221/32845401.png" alt="img1" id="btnSocial" class="social4"/>
Answer: Use the CSS background-image property You can simply use the CSS background-image property in combination with the :hover pseudo-class to replace or change the image on mouseover.
Zoom images/videos on all your favorite websites (Facebook, Amazon, etc). Simply hover your mouse over the image to enlarge it. Hover your mouse over any image on the supported websites and the extension will automatically enlarge the image to its full size, making sure that it still fits into the browser window.
Answer: Use the CSS transform property.
Use transform: scale(x, y)
to scale the object.
Use transform: translate(x, y)
to move the object.
Those two properties can also be combined: transform: scale(x, y) translate(x, y)
.
Example:
.btn-social {
width: 100px;
position: relative;
opacity: 0.5;
transition: 0.3s ease;
cursor: pointer;
}
.btn-social:hover {
opacity: 1;
/** default is 1, scale it to 1.5 */
transform: scale(1.5, 1.5);
/** translate 50px from left, and 40px from top */
/** transform: translate(50px, 40px); */
/** combine both scale and translate */
/** transform: scale(1.5, 1.5) translate(50px, 40px); */
}
<img src="http://sstatic.net/stackexchange/img/logos/so/so-icon.png?v=c78bd457575a" class="btn-social" />
<img src="http://sstatic.net/stackexchange/img/logos/so/so-icon.png?v=c78bd457575a" class="btn-social" /><br />
<img src="http://sstatic.net/stackexchange/img/logos/so/so-icon.png?v=c78bd457575a" class="btn-social" />
<img src="http://sstatic.net/stackexchange/img/logos/so/so-icon.png?v=c78bd457575a" class="btn-social" />
Check this http://jsfiddle.net/tNLUx/11/
Removed position: relative;
from css
#btnSocial{
width:100px;
opacity: 0.5;
-webkit-opacity: 0.5;
-moz-opacity: 0.5;
transition: 0.5s ease;
-webkit-transition: 0.5s ease;
-moz-transition: 0.5s ease;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With