源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

js实现彩色条纹滚动条效果

  • 时间:2022-11-03 08:13 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:js实现彩色条纹滚动条效果
[b]左侧可用调色板选择条纹颜色[/b] [b]效果图:[/b] [img]http://files.jb51.net/file_images/article/201703/2017315105827564.png?2017215105847[/img] [b]代码如下:[/b]
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
*{margin:0; padding:0;}
@-webkit-keyframes demo{
 from{ left:0;}
 to{ left:-113px;}
}
.box{ width:120px; height:400px; border:1px solid #000; margin:100px auto; position:relative; overflow:hidden;}
.bar{ position:absolute; left:0; top:0; width:500px; height:400px; background: -webkit-repeating-linear-gradient(-45deg , red 0px, red 20px, #fff 20px, #fff 40px, blue 40px, blue 60px, #fff 60px, #fff 80px); animation:demo 2s linear infinite; }
</style>
<script>
window.onload = function(){
 var oC1 = document.querySelectorAll('input')[0];
 var oC2 = document.querySelectorAll('input')[1];
 var oBar = document.querySelector('.box .bar');
 oC1.onchange = oC2.onchange = function(){
 oBar.style.background = '-webkit-repeating-linear-gradient(-45deg , '+oC1.value+' 0px, '+oC1.value+' 20px, #fff 20px, #fff 40px, '+oC2.value+' 40px, '+oC2.value+' 60px, #fff 60px, #fff 80px)';
 };
};
</script>
</head>
<body>
 <input type="color" value="#ff0000" />
 <input type="color" value="#0000ff" /> 
 <div class="box">
 <div class="bar"></div>
 </div>
</body>
</html>
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持编程素材网!
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部