use*_*403 1 html css css-transforms css-animations css-shapes
基本上我正试图创建我在这个网站上找到的这种翻转效果
单击最右边的箭头(以查看在彩色部分最右侧悬停的箭头)可以看到对主标题和副标题的影响,这会使标题向上翻转.
我真的不知道怎么做这个效果,所以我在网上找到了一个例子,但问题是它有悬停状态,我无法理解如何让它在页面加载时自动启动而不是徘徊.正如你在这个例子中看到的那样,反面A和B都是彩色的,我希望从A面开始是背景白色,文字是白色然后将其翻转成彩色版本,所以用其他单词从不可见到可见.
在这里查看我的工作演示
此示例的代码如下:
/* Set-up */
body {
color: rgb(6, 106, 117);
text-transform: uppercase;
font-family: sans-serif;
font-size: 100%;
background: #F4F6F8;
padding: 3em 0 0 0;
line-height: 62px;
-webkit-perspective: 1000px; /* <-NB */
}
/* Container box to set the sides relative to */
.cube {
width: 30%;
text-align: center;
margin: 0 auto;
height: 100px;
-webkit-transition: -webkit-transform .33s;
transition: transform .33s; /* Animate the transform properties */
-webkit-transform-style: preserve-3d;
transform-style: preserve-3d; /* <-NB */
}
/* The two faces of the cube */
.flippety,.flop {
background: rgb(247, 247, 247);
border: 1px solid rgba(147, 184, 189, .8);
height: 100px;
}
/* Position the faces */
.flippety {
-webkit-transform: translateZ(50px);
transform: translateZ(50px);
}
.flop {
-webkit-transform: rotateX(-90deg) translateZ(-50px);
transform: rotateX(-90deg) translateZ(-50px);
}
/* Rotate the cube */
.cube:hover {
-webkit-transform: rotateX(89deg);
transform: rotateX(89deg); /* Text bleed at 90º */
}Run Code Online (Sandbox Code Playgroud)
<div class="cube">
<div class="flippety">
<h1>Flippity</h1>
</div>
<div class="flop">
<h2>Flop</h2>
</div>
</div>Run Code Online (Sandbox Code Playgroud)
我的目标:创建一个翻转立方体,在页面加载时自动翻转我的标题(无悬停).
如果有什么不清楚请告诉我,我会尽可能清楚地解释.谢谢!
在您给出的示例中,标题翻转没有3D变换.这是Y轴上的简单2D平移,如下所示:
div{
position:relative;
font-size:2em;
line-height:1.2em;
height:1.2em;
overflow:hidden;
}
h2{
font-size:1em;
margin:0; padding:0;
animation:slide .5s .5s ease-out forwards;
}
@keyframes slide {
to {transform:translateY(-1.2em);
}Run Code Online (Sandbox Code Playgroud)
<div id="titles">
<h2>this is title one</h2>
<h2>This is a second title</h2>
</div>Run Code Online (Sandbox Code Playgroud)