使用css3动画旋转Div

时间:2014-07-21 10:07:04

标签: css css3 animation css-animations

我只是需要一些帮助来推送我的代码。我创建了一个旋转div的css动画。它使用中心轴旋转3个大小为w-400的h-300像素。但是当我调整div的大小时,旋转轴不会居中,就像你在JSFiddle中看到的那样。我的代码如下。

JSFiddle for spinning div

我的CSS

 .hover-img {
            position: relative;
            width: 600px;
            height: 200px;
            -webkit-transition: all 1s ease-in-out;
            -moz-transition: all 1s ease-in-out;
            -ms-transition: all 1s ease-in-out;
            -o-transition: all 1s ease-in-out;
            transition: all 1s ease-in-out;
            background:url(http://www.wholesaleforeveryone.com/content/images/blank/600/solid_color.gif);
            -webkit-transform:rotateY(180deg);
            -webkit-transform-style: preserve-3d;
                line-height:600px;
            text-align:center;
            font-size:0;
            margin: 0 auto;
 }
.hover-img:hover{
           -webkit-transform:rotateY(0deg);
            font-size:14px;
            color:white;
}

HTML

<div class="row row2">
    <div class="column"><div class="hover-img"><p></p><img src="bottomleft.png" width="600" height="400" /> </div></div>
    <div class="column"><div class="hover-img"><p></p><img src="bottomright.png" width="600" height="400" /></div></div>
</div>

1 个答案:

答案 0 :(得分:0)

请更改hover-img课程

的css
.hover-img {
position: relative;
height: 300px;
-webkit-transition: all 1s ease-in-out;
-moz-transition: all 1s ease-in-out;
-ms-transition: all 1s ease-in-out;
-o-transition: all 1s ease-in-out;
transition: all 1s ease-in-out;
background: url(bbclike/topright.png);
-webkit-transform: rotateY(180deg);
-webkit-transform-style: preserve-3d;
line-height: 200px;
text-align: center;
font-size: 0;
margin: 0 auto;
}

删除空白段落。来自class="hover-img"

的子类