<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>scrollbar</title>
<style>
body{
padding: 0;
margin: 0;
}
.scrollbar{
height: 50vh;
overflow-x: hidden;
overflow-y: scroll;
/*opacity: 0.5;*/
}
.scrollbar::-webkit-scrollbar{
border: 0;
display: none;
/* width: 10px;
height: 20px;
display: block;
background-color: #eee;
opacity: 0.4;
position: absolute;
z-index: 99;
left: 0;*/
}
/* .scrollbar::-webkit-scrollbar-button{
background-color: #000;
width: 20px;
height: 22px;
cursor: wait;
}*/
.scrollbar:hover::-webkit-scrollbar{
width: 10px;
display: block;
background-color: transparent;
}
.scrollbar::-webkit-scrollbar-thumb{
background-color: #eee;
width: 20px;
height: 22px;
cursor: wait;
}
.scrollbar::-webkit-scrollbar-track{
position: absolute;
z-index: -1;
/*width: 1px;*/
/*width: 20px;*/
/*background-color: rgba(0, 0, 0, 0.4);*/
/*opacity: 0.5;*/
/* position: absolute;
z-index: 99;
left: 0;
top: 20px;*/
}
p {
background-color: #666;
color: #fff;
}
</style>
</head>
<body>
</body>
<script>
const target = document.querySelector('body')
let html = '<div class="scrollbar">', i =0;
// for(let i = 0; i < 50; i++)
while(i++ < 50) {
console.log(i)
html += `<p>test-----${i}-------</p>`
}
target.innerHTML = html + '</div>'
</script>
</html>
网友评论