【问题标题】:What to change ScrollBar color tied to a div element如何更改绑定到 div 元素的 ScrollBar 颜色
【发布时间】:2022-10-01 07:45:32
【问题描述】:

我创建了一个包含overflow-y: scroll; 的 div,但现在我正在尝试更改该滚动条颜色而不影响浏览器滚动条颜色。

.details{
    display: grid;
    grid-template-columns: repeat(5,1fr);
    grid-gap:4rem;
    
}

.ben-details,.lucy-details,.castle-details,.brett-details,.sheldon-details{
    background-color: #421803;
    height:10rem;
    overflow-y: scroll;
    scroll-behavior: smooth;
    margin-left: 2rem;
}



.ben-details h6,.lucy-details h6,.castle-details h6,.brett-details h6,.sheldon-details h6{
text-align: center;
color: #421803;
font-size: 12px;
}

.ben-details p,.lucy-details p,.castle-details p,.brett-details p,.sheldon-details p{
    text-align: justify;
    color: #B99C7E;
    font-size: 10px;
    max-width: 6rem;
    
}
 <div class=\"details\">

        <div class=\"ben-details\">
        <h6>Marketing Leading</h6>
          <p>With 5 years experience in marketing, 
            Ben does a great job of marketing our brand</p>
        </div>

        
        <div class=\"lucy-details\">
          <h6>Head of HR</h6>
          <p>Lucy is the head of HR, she works with the company and the 
            employees to retain existing employees and hiring new talent.</p>
        </div>

        
        <div class=\"castle-details\">
          <h6>Sales Lead</h6>
          <p>Castle is our lead Sales and his core values are building a 
            respectful and trusting relationships with our clients.</p>
        </div>

        <div class=\"brett-details\">
          <h6>CEO</h6>
          <p>Brett built this company from the ground up and is proud of where it is today.
            He works with the company to help accomplish the company goals. He believes good 
            leaders step up and work along with thier employees.
          </p>
        </div>

        <div class=\"sheldon-details\">
          <h6>Front-End Developer</h6>
          <p>Sheldon is a talented Front-End Developer who works with the Marketing lead to
            keep our beautiful website up to date with our current and new products.
          </p>
        </div>

      </div>

我确实在以下 div 类下尝试了scrollbar-color:#B99C7E

  • 本-详细信息
  • lucy-详细信息
  • 城堡细节
  • brett-详细信息
  • 谢尔顿详细信息

但没有运气。我知道 ::-webkit-scrollbar 会改变浏览器滚动条,但不是我想要的。

我附上了一个截图,由于某种原因,它在控制台上禁用了滚动条颜色。

    标签: html css


    【解决方案1】:

    滚动条颜色有两部分:拇指颜色和轨道颜色

    例如滚动条颜色:黑灰色

    这将使背景变灰,滚动条上的拇指变黑。

    【讨论】:

    • 不幸的是,我以.ben-details 为例进行了尝试。它不工作
    猜你喜欢
    • 2016-01-14
    • 2021-05-18
    • 2015-08-15
    • 1970-01-01
    • 2022-01-05
    • 1970-01-01
    • 2020-10-31
    • 1970-01-01
    相关资源
    最近更新 更多