CSS 过渡 - rotateX 只是改变我的元素的大小

标签 css rotation size 2d transition

我对 CSS 过渡有疑问。 我的网站上有两个按钮 ( here ),当鼠标按住它时,它们应该被推回到底部,就像在 Windows 8 开始菜单上一样。 相反,发生的事情是它只是改变了我的元素的大小,就像 2D 过渡一样,我能注意到的任何 3D 都是元素被推回到顶部。即使我将度数设置为正数或负数,这也没有什么不同。 如果有人可以帮助我,我将不胜感激,谢谢。 :)

,#metroicons 是容器,.metro 是我要旋转 3d 的元素,.metro img 是 div 内的图像,而 .metro div 是元素内的一些文本。大家可以自己看看here .

#metroicons {
    padding-left: 5px;
    padding-top: 5px;
    perspective: 1000;
}

.metro {
    display: inline-block;
    height: 120px;
    transform-style: preserve-3d;
    transition: transform 0.25s linear;
    box-shadow: 5px 5px 30px #000;
}
.metro:active {
    transform: rotateX(40deg);
}
.metro img {
    width: 30%;
    height: 45%;
    margin-left: 35%;
    margin-top: 13%;
}
.metro div {
    font-family: Segoe UI, Frutiger, Frutiger Linotype, Dejavu Sans, Helvetica Neue, Arial, sans-serif;
    color: #fff;
    font-size: 14px;
    margin-left: 5px;
    margin-top: 15px;
}

最佳答案

帮助您入门。

<div class="tile">
</div>

div.tile {
    width:100px;
    height:100px;
    margin:20px;
    background:red;
    -webkit-animation: example 0.75s ease 0s infinite alternate;
}
@-webkit-keyframes example {
    from {
       -webkit-transform: perspective(300) rotateX(-45deg);
       -webkit-transform-origin: 0% 0%;
    }
    to {
       -webkit-transform: perspective(300) rotateX(0deg);
        -webkit-transform-origin: 0% 0%;
    }
}

https://jsfiddle.net/5x0uunkz/

关于CSS 过渡 - rotateX 只是改变我的元素的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29059566/

相关文章:

javascript - 如何旋转外部对象

java - 如何打开具有预定义大小的 JFileChooser

mysql - 维基百科转储表页面链接的问题

javascript/css 样式并未实现到所有按钮

css - 无法将背景图像添加到 Jumbotron for Rails App

android - 如何使 Android Button 的 drawableLeft 保持旋转?

html - 旋转div时如何显示不同的内容

html - 窗口尺寸小(比页面窄)页面结构出错

html - Chrome 中的慢速聚焦输入字段

html - Bootstrap 4 div 高度不扩展以适合内容