CSS:鼠标悬停更改图像位置和大小

ini*_*tar 14 html css hover

我正在尝试为我的网站做一个按钮菜单,我对鼠标悬停时图像的位置有疑问.这是我到目前为止创建的http://jsfiddle.net/tNLUx/

在鼠标悬停时,我希望所选图像增长,而其他图像保持相同的位置,就像第一张图像一样......如何使向下图像增长并向下移动而不是向上移动?

这是我的一些CSS

#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;
}
Run Code Online (Sandbox Code Playgroud)

谢谢你的时间

干杯

nov*_*ung 39

使用transform: scale(x, y)缩放对象.
使用transform: translate(x, y)移动的对象.
这两个属性也可以合并:transform: scale(x, y) translate(x, y).

例:

.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); */
}
Run Code Online (Sandbox Code Playgroud)
<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" />
Run Code Online (Sandbox Code Playgroud)