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

左侧可用调色板选择条纹颜色

效果图:

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

代码如下:

<!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> <div></div> </div> </body> </html>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wwwgyx.html