CSS平滑过渡动画:transition
2024-08-24 12:23:11
<html>
<head>
<link href="http://cdn.bootcss.com/twitter-bootstrap/3.0.2/css/bootstrap.css" rel="stylesheet">
<style>
body{
margin-top: 30px;
}
.box {
width: 400px; padding: 15px; background-color: #f0f3f9;
}
.content {
height: 0; position: relative; overflow: hidden;
-webkit-transition: height 0.6s;
-moz-transition: height 0.6s;
-o-transition: height 0.6s;
transition: height 0.6s;
}
.content img {
position: absolute; bottom: 0;
}
.block{
margin: 20px 20px 20px 0;
width:100px;
height:100px;
background:blue;
transition:background 2s, width 2s;
} .block:hover{
width:300px;
background:red;
} </style>
</head>
<body>
<div class="container">
<div class="block"></div>
<a href="javascript:" class="btn btn-primary" id="button">点击展开图片</a>
<div id="more" class="content">
<img src="http://i1.hoopchina.com.cn/u/1403/26/425/2709425/3076ecc2.jpg" height="191" />
</div>
</div> <script>
(function() {
var Btn = document.getElementById("button"),
More = document.getElementById("more"); var display = false; Btn.onclick = function() {
display = !display;
More.style.height = display? "192px": "0px"
return false;
};
})();
</script>
</body>
</html>
最新文章
- CAST function should support INT synonym for SIGNED. i.e. CAST(y AS INT)
- Qt StyleSheet样式表实例(转)
- Java SSH库使用简介:Apache sshd和JSch(Java Secure Channel)
- 安装PIL库时提示python未注册错误(自定义python安装路径)
- The Accomodation of Students(判断二分图以及求二分图最大匹配)
- intel hex 格式的几个链接
- 摘抄详细的VUE生命周期
- grep 及正则表达式
- QT之Http请求
- myeclipse安装spring插件
- java连接Mysql8
- mycql 多表联合查询
- toggle显示与隐藏切换
- VS2017上在线和离线安装Qt插件(在线安装)
- 大话设计模式C++ 适配器模式
- Leetcode 5016. 删除最外层的括号
- Go Example--map
- 设置ListView显示到最后一行
- 流行的软件工程过程--Rational统一过程!
- 按照Right-BICEP要求设计四则运算2程序的单元测试用例