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>

最新文章

  1. echarts之tooltip-showContent
  2. 重构8-Replace&#160;Inheritance&#160;with&#160;Delegation(委托替换继承)
  3. 【转】iOS学习之Autolayout(代码添加约束) -- 不错不错
  4. 告别where 1=1 最佳方案分享
  5. hdu 2243 考研路茫茫——单词情结 ac自动机+矩阵快速幂
  6. C# VS2010中,用微软自带的System.Data.OracleClient来连接Oracle数据库
  7. HW4.26
  8. 在CENTOS6上安装MONGODB
  9. JSP项目前端优化
  10. C-switch case之如何巧妙判断范围区域
  11. 在Java中调用与系统有关的剪切板Clipboard
  12. (DIjsktra算法) nyoj1401-一场说走就走的旅行
  13. DataTable插件 后台分页 (服务器端分页)
  14. cent7安装ffmpeg
  15. #CSS margin-top父元素下落
  16. 多线程编程中的EventWaitHandler
  17. [leetcode]Simplify Path @ Python
  18. English trip -- VC(情景课) 7 A Shopping 购物
  19. Centos6.6系统root用户密码恢复案例
  20. Django中的CBV和FBV

热门文章

  1. trait 和abstract的区别在哪里
  2. node jsonwebtoken
  3. Javaweb 使用Servlet技术改写用户登录 使用Filter技术解决中文乱码
  4. position:搜索框显示历史浏览记录
  5. [tyvj1935 Poetize3]导弹防御塔 (二分图多重匹配)
  6. Java核心技术读书笔记02
  7. redis在windows上通过cmd连接服务器(需要密码)
  8. 1.VMware虚拟机的安装
  9. 1 java开发工具IDEA的使用
  10. POJ 1703 Find them, Catch them(并查集高级应用)