gpt4 book ai didi

html - 如何使动画在 css3 中每次都能工作

转载 作者:太空宇宙 更新时间:2023-11-04 13:27:09 24 4
gpt4 key购买 nike

我使用带有一些动画的 css3 制作了制表符。当您第一次单击选项卡时,动画效果很好,但当您再次单击同一个选项卡时,动画效果不佳,而且即使是第一次在 chrome 中,动画也无法正常工作。 fiddle

//CSS

body {font-size:14px}
p{ margin:0; padding:0}
input[type=radio]{ display:none}
section[id^=tab]{ display:none}
section{border:1px solid #CCCCCC; width:650px; padding:10px; position:absolute; top:35px}
section p {-webkit-animation: growUp 0.4s ;}
label{border:1px solid #CCCCCC; float:left; border-bottom:none; padding:5px 15px; position:relative; margin-left:-1px; left:1px; cursor:pointer; background:#EEEEEE; z-index:-1}
input[type=radio][id=tb1]:checked~section#tab-1{ display:block}
input[type=radio][id=tb1]:checked~label[for=tb1]{ background:#fff; z-index:1}
input[type=radio][id=tb2]:checked~section#tab-2{ display:block}
input[type=radio][id=tb2]:checked~label[for=tb2]{ background:#fff; z-index:1}
input[type=radio][id=tb3]:checked~section#tab-3{ display:block}
input[type=radio][id=tb3]:checked~label[for=tb3]{ background:#fff; z-index:1}
input[type=radio][id=tb4]:checked~section#tab-4{ display:block}
input[type=radio][id=tb4]:checked~label[for=tb4]{ background:#fff; z-index:1}
@keyframes growUp {
0% { transform:scale(0); -webkit-transform:scale(0); }
100% { transform:scale(1); -webkit-transform:scale(1); }
}

//HTML

<div class="fl">
<input type="radio" name="tab" id="tb1" checked="checked" />
<label for="tb1">Tab1</label>
<section id="tab-1"><p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s</p></section>
</div>
<div class="fl">
<input type="radio" name="tab" id="tb2" />
<label for="tb2">Tab2</label>
<section id="tab-2">
<p>
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
</p>
</section>
</div>
<div class="fl">
<input type="radio" name="tab" id="tb3" />
<label for="tb3">Tab3</label>
<section id="tab-3">
<p>
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
</p>
</section>
</div>
<div class="fl">
<input type="radio" name="tab" id="tb4" />
<label for="tb4">Tab4</label>
<section id="tab-4">
<p>
There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form
</p>
</section>
</div>

最佳答案

如果你想在 safari 或 chrome 等 webkit 引擎浏览器上使用它,你必须为 css3 动画使用 -webkit- 前缀,

例如

@-webkit-keyframes growUp
/* Safari and Chrome */
{
0% {
transform:scale(0);
-webkit-transform:scale(0);
}
100% {
transform:scale(1);
-webkit-transform:scale(1);
}
}

这是您的解决方案 fiddle

关于html - 如何使动画在 css3 中每次都能工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23625242/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com