用opcity模拟zindex渐变的效果
2024-09-07 15:20:12
github地址:
https://github.com/echoorx/opacity-Gradient
zindex好像不能渐变改变,所以用opcity来模拟
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
div{
width: 100px;
height: 100px;
position: absolute;
top: 0;
}
.big{
background-color: red;
}
.small{
background-color: green;
z-index: 1;
opacity: 0;
}
#btn{
margin-top: 200px;
}
</style>
</head>
<div class="big"></div>
<div class="small"></div>
<input id="btn" value="1111" type="button">
<body>
<script>
var btn = document.querySelector('#btn');
var small = document.querySelector('.small')
btn.addEventListener('click',function(){
var timer = setInterval(function(){
var opc = window.getComputedStyle(small, null)["opacity"];
opc = opc * 100 + 2;
opc /= 100;
small.style.opacity = opc;
if(opc == 1){
clearInterval(timer)
}
},10)
})
</script>
</body>
</html>
最新文章
- echarts之tooltip-showContent
- 重构8-Replace&#160;Inheritance&#160;with&#160;Delegation(委托替换继承)
- 【转】iOS学习之Autolayout(代码添加约束) -- 不错不错
- 告别where 1=1 最佳方案分享
- hdu 2243 考研路茫茫——单词情结 ac自动机+矩阵快速幂
- C# VS2010中,用微软自带的System.Data.OracleClient来连接Oracle数据库
- HW4.26
- 在CENTOS6上安装MONGODB
- JSP项目前端优化
- C-switch case之如何巧妙判断范围区域
- 在Java中调用与系统有关的剪切板Clipboard
- (DIjsktra算法) nyoj1401-一场说走就走的旅行
- DataTable插件 后台分页 (服务器端分页)
- cent7安装ffmpeg
- #CSS margin-top父元素下落
- 多线程编程中的EventWaitHandler
- [leetcode]Simplify Path @ Python
- English trip -- VC(情景课) 7 A Shopping 购物
- Centos6.6系统root用户密码恢复案例
- Django中的CBV和FBV
热门文章
- trait 和abstract的区别在哪里
- node jsonwebtoken
- Javaweb 使用Servlet技术改写用户登录 使用Filter技术解决中文乱码
- position:搜索框显示历史浏览记录
- [tyvj1935 Poetize3]导弹防御塔 (二分图多重匹配)
- Java核心技术读书笔记02
- redis在windows上通过cmd连接服务器(需要密码)
- 1.VMware虚拟机的安装
- 1 java开发工具IDEA的使用
- POJ 1703 Find them, Catch them(并查集高级应用)