gpt4 book ai didi

html - 显示和隐藏类 (onClick)

转载 作者:行者123 更新时间:2023-11-28 08:19:51 25 4
gpt4 key购买 nike

上传我在按钮上使用 Bootstrap 3 中的字形图标,它使用 CSS3 关键帧旋转,我想(.hide)这个类,直到单击按钮,然后它会出现/显示,然后旋转。 ..像它一样生动?

这是我的 fiddle :

http://jsfiddle.net/DannyJardine/8djrcwnb/4/

<span class="glyphicon glyphicon-refresh glyphicon-refresh-animate"></span>
Upload</button>

最佳答案

您可以将 css 用于此类功能,并使用 jQuery 的 toggleClass 属性:

$('button').click(function() {
$('.togglable').toggleClass("active");
});
button {
height: 50px; /*just some styling for the button*/
width: 50px;
border-radius: 50%;
background: red;
box-shadow: inset 2px 2px 10px white, inset -2px -2px 10px black;
outline: none;
}
.togglable {
font-size: 0;
height: 0;
width: 0;
transition: all 1s; /*speed of animation*/
transform-origin:center center;
text-align:center;
margin:0 auto;
}
.active {
font-size: 50px;
height: 50px;
width: 400px;
transform: rotate(720deg); /*multiple of 360 to ensure animation finishes 'straight'*/
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button></button>
<div class="togglable active">Press the red button to toggle me!!!</div>

关于html - 显示和隐藏类 (onClick),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28813320/

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