尝试将滚动条设置为黑色并始终可见



需要将滚动条颜色设置为黑色并始终可见。这是我的例子

现在滚动条是白色的,只有在滚动时才可见。这是我的css:

[data-scroller="true"] {
overflow: hidden;
}
.scroller-scrollbar {
display: none;
position: absolute;
z-index: 1000;
border-top-right-radius: 2px;
border-top-left-radius: 2px;
border-bottom-right-radius: 2px;
border-bottom-left-radius: 2px;
}
.scroller-scrollbar.vertical {
top: 0;
right: 0;
width: 3px;
height: 100%;
margin: 0 2px;
}
.scroller-scrollbar.vertical.scroller-inverse {
left: 0;
right: inherit;
}
.scroller-scrollbar.horizontal {
left: 0;
bottom: 0;
width: 100%;
height: 3px;
margin: 2px 0;
}
.scroller-scrollbar.horizontal.scroller-inverse {
top: 0;
bottom: inherit;
}
.scroller-scrollbar.scroller-active {
display: block;
}
.scroller-scrollbar {
background-color: #000;
opacity: 0.32;
}
这是我的HTML:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Fxp Jquery Scroller Basic Example</title>
<link href="https://www.jqueryscript.net/css/jquerysctipttop.css" rel="stylesheet" type="text/css">
<link href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css" rel="stylesheet" type="text/css">
<link href="scroller.css" rel="stylesheet">
<style>
body {
background: #fafafa;
}
.container { margin: 150px auto; max-width: 960px; }
.content {
background: #eee;
height: 200px;
width: 300px;
border-radius: 3px solid #222;
}
p { padding: 2rem 1rem; }
</style>
</head>
<body><div id="jquery-script-menu">
<div class="jquery-script-center">
<ul>
<li><a href="https://www.jqueryscript.net/other/custom-fxp-scroller.html">Download This Plugin</a></li>
<li><a href="https://www.jqueryscript.net/">Back To jQueryScript.Net</a></li>
</ul><div id="carbon-block"></div>
<div class="jquery-script-ads"><script type="text/javascript"><!--
google_ad_client = "ca-pub-2783044520727903";
/* jQuery_demo */
google_ad_slot = "2780937993";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="https://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<div class="jquery-script-clear"></div>
</div>
</div>
<textarea class="content container" data-scroller="true" data-prevent-mouse-scroll="true" style="overflow-y: scroll; border-radius: 25px;" rows="10" cols="10">
"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?""But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?""But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?""But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?""But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"
</textarea>
<script src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ" crossorigin="anonymous"></script>
<script src="scroller.js" async="async"></script>
<script>
try {
fetch(new Request("https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js", { method: 'HEAD', mode: 'no-cors' })).then(function(response) {
return true;
}).catch(function(e) {
var carbonScript = document.createElement("script");
carbonScript.src = "//cdn.carbonads.com/carbon.js?serve=CK7DKKQU&placement=wwwjqueryscriptnet";
carbonScript.id = "_carbonads_js";
document.getElementById("carbon-block").appendChild(carbonScript);
});
} catch (error) {
console.log(error);
}
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-36251023-1']);
_gaq.push(['_setDomainName', 'jqueryscript.net']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</body>
</html>

您可以使用::-webkit-scrollbar{}来定位滚动条并更改其外观。

您还可以使用.div_class{ overflow-y:scroll;}来始终在所需的div中显示滚动条。

查看下面的代码片段

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
*{
font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
}
.blur_container{
border-radius: 20px;
width:450px;
height: 450px;
background-image: url("https://picsum.photos/450/450");
display:flex;
justify-content: center;
align-items: center;
}
.blur_cont{
width: 425px;
height: 425px;
color: rgb(0, 0, 0);
border-radius: 20px;
background-color: #aec2eb48;
vertical-align: middle;
text-align: center;
backdrop-filter: blur(8px);
overflow-y: scroll;
}
.body_text{
padding: 20px;
}
/* width */
::-webkit-scrollbar {
width: 10px;
}
/* Track */
::-webkit-scrollbar-track {
background: #9e9a9a; 
}

/* Handle */
::-webkit-scrollbar-thumb {
background: rgb(54, 54, 54); 
}
/* Handle on hover */
::-webkit-scrollbar-thumb:hover {
background: rgb(0, 0, 0); 
}
</style>
</head>
<body>
<div class="blur_container">
<div class="blur_cont">
<p class="body_text">
<span style="font-size:60px; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;">Purchace</span><br> 
Premium to veiw
</p>
<br>
<p>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Quisquam incidunt cumque veniam eum aperiam quis commodi sequi recusandae voluptates nam eligendi unde quos quia modi rem ratione, aliquam eos numquam?
Lorem ipsum, dolor sit amet consectetur adipisicing elit. Quibusdam id omnis cupiditate non at dolore! Quia odio quos numquam beatae, libero neque vel quam excepturi dolores. Eum quidem expedita iure!
Lorem ipsum dolor sit amet consectetur adipisicing elit. Nihil explicabo qui aspernatur ex, quas itaque accusantium quibusdam aliquam consequuntur architecto reprehenderit error harum libero! Ipsam fugiat error cupiditate eveniet non?
Lorem ipsum, dolor sit amet consectetur adipisicing elit. Nisi consequatur quo perferendis quibusdam. Ad iusto minima saepe laboriosam, omnis eaque tempore officia facere, quisquam cum adipisci culpa voluptatibus dolorum! Error?
</p>
</div>
</div>
</body>
<script>
</script>
</html>

html ::-webkit-scrollbar {
width: 15px;
}
html ::-webkit-scrollbar-thumb {
height: 7rem;
border-radius: 0.8rem;
border: 0.2rem solid transparent;
background-clip: content-box;
background-color: #000000;
}

::-webkit-scrollbar用于设置滚动条的css,::-webkit-scrollbar-thumb用于设置拇指的css

试试这个

最新更新