![](https://img.haomeiwen.com/i14922463/9f16a2e1acc0907a.gif)
--bug [高度自适应不能触发transition的解决方法]
通过设置max-height 来实现
代码我就全复制了
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<!-- 引用jq文件 -->
<!-- <script src="http://code.jquery.com/jquery-latest.js"></script> -->
<script src="./util/zepto/dist/zepto.js"></script>
<style>
button{
border:none;
outline: none;
}
.Coupon{
background-color: orange;
height: 40px;
width: 180px;
color: #fff;
}
.Coupon_frame {
position: fixed;
bottom: 0px;
left: 0px;
max-height: 200px;
right: 0px;
background-color: #ccc;
text-align: center;
line-height: 400px;
transition: max-height 2s;
}
.Coupon_frame_animate{
max-height: 0px;
}
ul{
list-style: none;
background-color: aquamarine;
}
li{
height: 20px;
line-height: 20px;
}
</style>
</head>
<body id="box">
<button class="Coupon">优惠卷</button>
<p>内容</p>
<p>内容</p>
<p>内容</p>
<p>内容</p>
<p>内容</p>
<p>内容</p>
<p>内容</p>
<p>内容</p>
<p>内容</p>
<p>内容</p>
<p>内容</p>
<p>内容</p>
<p>内容</p>
<p>内容</p>
<p>内容</p>
<p>内容</p>
<p>内容</p>
<p>内容</p>
<p>内容</p>
<div class="Coupon_frame">
<ul>
<li>卷1</li>
<li>卷2</li>
<li>卷3</li>
<li>卷4</li>
<li>卷5</li>
<li>卷3</li>
<li>卷4</li>
<li>卷5</li>
</ul>
</div>
</body>
</html>
<script>
$(".Coupon").on('tap',function(){
$(".Coupon_frame").toggleClass('Coupon_frame_animate')
})
</script>
网友评论