Mouse hover change image position and size
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;
}