使用外部按钮控制 CSS 变换?
需要按钮上的 javascript 帮助来触发这些转换,例如滑块 1、2、3 以及来回交替。就像苹果网站上的 iPhone 功能滑块一样。有人吗?
HTML:
<div id="anima-slide1">
<div class="anima-text-slide1">Genuinity comes at a price.<br>
<font color="#f06">Will you pay it?</font></div>
<div class="anima-image-slide1"><img src="img/lowrider1.png" width="250" height="250"> </div>
</div>
<div id="anima-slide2">
<div class="anima-text-slide2">Genuinity comes at a price.<br>
<font color="#f06">Will you pay it?</font></div>
<div class="anima-image-slide2"><img src="img/lowrider1.png" width="250" height="250"> </div>
</div>
<div id="anima-slide3">
<div class="anima-text-slide3">Genuinity comes at a price.<br>
<font color="#f06">Will you pay it?</font></div>
<div class="anima-image-slide3"><img src="img/lowrider1.png" width="250" height="250"> </div>
</div>
CSS:(2 和 3 相同)
.anima-text-slide1 {
margin-top:10px;
position:absolute;
font-family: 'BebasRegular';
color:#FFF;
font-size:40px;
}
.anima-text-slide1 {
-webkit-backface-visibility: visible;
-webkit-transition: 900ms ease;
opacity: 0;
-webkit-transform: translate(-497px, 0px) rotate(0deg);
}
.anima-image-slide1 {
position:absolute;
left: 610px;
top: 0px;
}
.anima-image-slide1 {
-webkit-backface-visibility: visible;
-webkit-transition: 900ms ease;
opacity: 0;
-webkit-transform: translate(497px, 0px) rotate(0deg);
}
Need help with a javascript on a button to trigger these transformations like a slider 1,2,3 and alternate back and forth. Like on the apple website for iPhone features slider. Anyone?
The HTML:
<div id="anima-slide1">
<div class="anima-text-slide1">Genuinity comes at a price.<br>
<font color="#f06">Will you pay it?</font></div>
<div class="anima-image-slide1"><img src="img/lowrider1.png" width="250" height="250"> </div>
</div>
<div id="anima-slide2">
<div class="anima-text-slide2">Genuinity comes at a price.<br>
<font color="#f06">Will you pay it?</font></div>
<div class="anima-image-slide2"><img src="img/lowrider1.png" width="250" height="250"> </div>
</div>
<div id="anima-slide3">
<div class="anima-text-slide3">Genuinity comes at a price.<br>
<font color="#f06">Will you pay it?</font></div>
<div class="anima-image-slide3"><img src="img/lowrider1.png" width="250" height="250"> </div>
</div>
The CSS: (Same for 2 and 3)
.anima-text-slide1 {
margin-top:10px;
position:absolute;
font-family: 'BebasRegular';
color:#FFF;
font-size:40px;
}
.anima-text-slide1 {
-webkit-backface-visibility: visible;
-webkit-transition: 900ms ease;
opacity: 0;
-webkit-transform: translate(-497px, 0px) rotate(0deg);
}
.anima-image-slide1 {
position:absolute;
left: 610px;
top: 0px;
}
.anima-image-slide1 {
-webkit-backface-visibility: visible;
-webkit-transition: 900ms ease;
opacity: 0;
-webkit-transform: translate(497px, 0px) rotate(0deg);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过添加类名,您可以创建多个动画步骤。使用 jQuery 可以更轻松地更改目标元素上的类名称。您可以将此技术应用于您的特定情况。
JS:
CSS:
编辑:
所以如果你想处理多个元素,你可以这样做:
然后:
By adding a class name you can create several animation steps. Using jQuery makes it a lot easier to change the class names on the target element. You can apply this technique to your particular situation.
JS:
CSS:
EDIT:
So if you want to do multiple elements you can do something like this:
Then: