动态上涨
来源:互联网 发布:吉利电动车知豆d1 编辑:程序博客网 时间:2024/06/10 05:10
<!doctype html><html lang="zh-cn"><head> <meta charset="UTF-8"> <title>动态上涨</title> <style type="text/css"> #parentBox{ width: 200px; height: 200px; border: 1px dashed #666; margin: 0 auto; overflow: hidden; /*让文本超出隐藏*/ } #childBox{ width:200px; background: #f00; } </style></head><body> <div id="parentBox"> <div id="childBox"> <p id="content" style="display:none;">内容区域内容区域内容区域内容区域内容区域内容区域内容区域内容区域内容区域</p> </div> </div> <script type="text/javascript"> //获取dom对象 var parentBox=document.getElementById("parentBox"); var childBox=document.getElementById("childBox"); var content=document.getElementById("content"); upHeight(parentBox,childBox,100); //upHeight为上涨的高度 //parentBox为父容器 //childBox为动态上涨部分 //showHeight为想要让他上涨的高度(预期高度); function upHeight(parentBox,childBox,showHeight){ parentBox.style.position="relative"; childBox.style.position="absolute"; childBox.style.bottom=0; childBox.style.height=0+"px"; var interval; parentBox.onmouseenter=function(){ if(interval!=-1){//判断定时器是否清零 clearInterval(interval); } interval=setInterval(function(){ var height=parseFloat(childBox.style.height); height+=10; if(height>=showHeight){ height=showHeight; clearInterval(interval); } childBox.style.height=height+"px"; },100); content.style.display="block"; }; parentBox.onmouseleave=function(){ if(interval!=-1){ clearInterval(interval); } interval=setInterval(function(){ var height=parseFloat(childBox.style.height); height-=10; if(height<=0){ height=0; clearInterval(interval); //把display放在定时器中,内容跟随下降消失,不会立刻消失。 content.style.display="none"; } childBox.style.height=height+"px"; },100); } } </script></body></html>
0 0
- 动态上涨
- 油价上涨 房价上涨 菜价上涨 下一个上涨的是什么?
- 房价为何上涨?
- 房价上涨的新闻
- 上涨之虞
- 物价为什么会上涨
- 魔兽与油价上涨
- 应对物价上涨
- 不断上涨不断加空仓
- 一季度物价上涨厉害
- 圆形上涨进度条
- 我市2月CPI同比上涨9% 食品类上涨6.3%
- 房价上涨难以动摇,2016年持续上涨的局面。
- 不赞成旺季交通费用上涨
- 单日上涨百点再现
- 房价上涨是万恶之首。。
- 房价或现报复性上涨
- 全智贤拉动达芙妮股价上涨
- 数据可视化漫谈(四)
- HDOJ2004
- opencv编程简介
- 【POJ2891】【一般模线性方程 模板题】Strange Way to Express Integers
- php日期转时间戳,指定日期转换成时间戳
- 动态上涨
- 环境配置与数据库连接
- ebs 双节点
- 意外死机后AndroidStudio满屏红线的解决方式
- lsof命令与fuser命令详解
- 我的‘’第一次‘’。。
- CRecordset::IsBOF和CRecordset::IsEOF区别
- Android:项目实战学习笔记
- Codeforces Round #364 (Div. 1) C.Break Up