0

我正在尝试使用 CSS3 过渡来使其中的图像在悬停<div>时向上移动 10 个像素。<div>它在 Firefox 中运行良好,但是当我在 Chrome 和 Safari 中查看它时,<h3><p>元素会上下抖动。

这是我的 CSS:

.feature-table #box {
    width: 325px;
    height: 372px;
    margin-right: 20px;
    float: left;
}

.feature-table a {
    display: block;
    width: 325px;
    height: 372px;
}

.feature-table a img {
    display: block;
    margin-left: auto;
    margin-right: auto;
    padding-top: 54px;
    padding-bottom: 40px;
    -moz-transition: all 0.3s linear;
    -webkit-transition: all 0.3s linear;
    transition: all 0.3s linear;
}

.feature-table a: hover img {
    padding-top: 44px;
    padding-bottom: 50px;
}

.feature-table a h3 {
    font-family: 'GothamBold', sans-serif;
    font-size: 30px;
    color: #3d3d3d;
    text-align: center;
    text-decoration: none;
    margin: 0;
    padding: 0 25px;
}

.feature-table a: hover h3 {
    color: #f6ce4f;
}

.feature-table a {
    text-decoration: none;
}

.feature-table p {
    font-family: 'GothamLight', sans-serif;
    font-size: 14.5px;
    color: #949494;
    text-align: center;
    padding: 10px 28px;
}

.feature-table .caret {
    border-top: 5px solid #fff;
    border-bottom: 5px solid #fff;
    border-left: 5px solid #ffc235;
    content: "";
    display: inline-block;
    height: 0;
    width: 0;
    margin-left: 10px;
}

这是我的 HTML 的一部分:

<div id="box">
    <a href="#">
        <img src="images/payment_icon.png" width="114" height="115" border="0" />
        <h3>Customizable Campaign Pages</h3>
        <p>Tell your story with images, video, rich text and social updates<b class="caret"></b></p>
    </a>
</div>

有任何想法吗?

4

1 回答 1

0

这可能是一个性能问题,因为您正在为影响当前布局的 2 个不同属性设置动画。
理想的解决方案是使用不影响其他元素的特定道具。在您的情况下,可以top在将图像的位置设置为之后使用属性来完成relative

a img{
    position : relative;
    top : 0;
}
a:hover img{
    top : -4px;
}

这是一个工作演示:http: //jsfiddle.net/p7Lxz/

于 2012-06-23T18:51:09.907 回答