gpt4 book ai didi

css - 在内容上覆盖透明滚动条

转载 作者:行者123 更新时间:2023-11-28 12:06:12 26 4
gpt4 key购买 nike

我有一个透明的滚动条,我想把它覆盖在内容上,而不是将内容推到左边。

enter image description here

最佳答案

如果你使用这个:

body {
overflow: overlay;
}

然后滚动条也会在整个页面上采用透明背景。这还将把滚动条放在页面内,而不是移除一些宽度以放入滚动条。

这是一个演示代码。我无法将它放入任何 codepen 或 jsfiddle 中,显然我花了一段时间才弄清楚,但它们没有显示透明度,我也不知道为什么。

但是把它放在一个 html 文件中应该没问题。

<!DOCTYPE html>
<html>
<style>
html, body {
margin: 0;
padding: 0;
}

body {
overflow: overlay;
}

.div1 {
background: grey;
margin-top: 200px;
margin-bottom: 20px;
height: 20px;
}

::-webkit-scrollbar {
width: 10px;
height: 10px;
}

::-webkit-scrollbar-thumb {
background: rgba(90, 90, 90);
}

::-webkit-scrollbar-track {
background: rgba(0, 0, 0, 0.2);
}
</style>

<body>

<div class="div1"></div>

<div class="div1"></div>

<div class="div1"></div>

<div class="div1"></div>

<div class="div1"></div>


</body>
</html>

您还可以将其应用于其他元素,例如任何滚动框。在使用检查器模式时,您可能必须将溢出隐藏起来,然后再返回到其他任何东西。它可能需要刷新。之后应该可以在滚动条上工作而不必再次刷新它。请注意,这是针对检查员模式的。

&nsbp;

请注意,这在 Internet Explorer 中不起作用。但是 Internet Explorer 有它自己的东西。


<STYLE>
<!--
HTML,BODY
{ color:black;
background-color:#a0a0a0;
scrollbar-face-color:#903030;
scrollbar-arrow-color:#FFFFFF;
scrollbar-track-color:#C0B0B0;
scrollbar-shadow-color:rgb(0,0,0);
scrollbar-highlight-color:rgb(0,0,0);
scrollbar-3dlight-color:#808080;
scrollbar-darkshadow-Color:#202020;
}
-->
</STYLE>

可以找到有关 IE 滚动条的更多信息 here .

关于css - 在内容上覆盖透明滚动条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39422963/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com