height不确定时,如何使用动画效果展开高度
2024-10-20 12:24:01
要点:
当元素 height 不确定时,可以使用 max-height 设置动画效果
a[href="foldBox"] 用于打开 #foldBox(利用伪元素 :target)
a[href="#"] 用于关闭 #foldBox
<style>
body { padding: 10px; }
.open {
display: inline-block;
font-weight: 800;
font-size: 18px;
text-decoration: none;
border: 1px solid ;
padding: 10px;
margin: 0 0 10px;
border-radius: 10px;
}
.foldBox {
overflow: hidden;
box-sizing: border-box;
width: 100%;
max-height: 0;
text-align: center;
border-radius: 10px;
transition: all .3s;
}
img {width: 30%;}
p {
font-weight: 800;
font-size: 20px;
}
.foldBox:target {
padding: 10% 0; /*该属性只能运用于元素展开后*/
max-height: 800px;
border: 1px solid ;
} </style>
<a class="open" href="#foldBox">What's this?</a>
<div id="foldBox" class="foldBox">
<img src="32.jpg">
<p>Are You Happy?</p>
<a href="#">YES</a>
</div>
最新文章
- mysql数据表拷贝
- C#拾遗-边边角角
- linux 重新编译低版本gcc
- Android Instrumention.sendPointerSync发送Event失败分析
- Java--concurrent并发包下阻塞队列介绍
- SharePoint Online 创建门户网站系列之准备篇
- Android虚拟机Classic qemu does not support SMP问题记录
- nodejs高大上的部署方式-PM2
- Android 签名工具 shell脚本
- LeetCode(一)
- uva 11922 Permutation Transforme/splay tree
- dom4j处理xml文件,读取xml字符串,格式化xml文件
- JavaIO(01)File类详解
- Google code: Why ‘Everything up-to-date’ when pushing (git)
- poj2352Stars
- UML--一些图
- hdu2089不要62(数位dp)
- 【百度地图API】多家地图API内存消耗对比测验(带源码)
- win10 Internet Explorer 11 停止工作处理
- 执行Sqlserver中waitfor delay延时操作或waitfor time定时操作