50% { width:80px} 表示宽度在0-5秒内由0变80px;
70% { border:15px solid yellow} 表示边框在0-7秒内由无边框变为15px实心的黄色边框;
100% { width:180pxheight:180px} 表示宽度从5-10秒变成180px,高度变成180px;
综上所述,前面的百分比,代表的是执行的时间,按秒来计算。
望采纳
用了JQ库,样式在style里,不过要配合js用<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="jquery-3.3.1.min.js"></script>
</head>
<style>
.div1{
text-align: center
background: beige
width: 50px
height: 28px
border-radius: 14px
}
.span1{
/* margin-top: 7px*/ /* div的时候打开注释 */
background: #CCCCCC
width: 13px
height: 13px
display: inline-block
border-radius: 7px
}
.div2{
text-align: center
background: lawngreen
width: 50px
height: 28px
border-radius: 14px
}
.span2{
background: white
width: 13px
height: 13px
display: inline-block
border-radius: 7px
}
.hid1{
display: none
}
.hid2{
}
</style>
<body>
<!-- button的 -->
<button class="div1">
<span class="hid1">是</span>
<span class="span1"></span>
<span class="hid2">否</span>
</button>
<hr>
<hr>
<!-- div的 -->
<!-- <div class="div1">
<span class="hid1">是</span>
<span class="span1"></span>
<span class="hid2">否</span>
</div>-->
</body>
<script>
$(function(){
$(".div1").click(function(){
$(".span1").toggleClass("span2")
$(".div1").toggleClass("div2")
$(".hid1").toggle()
$(".hid2").toggle()
})
})
</script>
</html>