本站消息

站长简介/公众号


站长简介:高级软件工程师,曾在阿里云,每日优鲜从事全栈开发工作,利用周末时间开发出本站,欢迎关注我的微信公众号:程序员总部,程序员的家,探索程序员的人生之路!分享IT最新技术,关注行业最新动向,让你永不落伍。了解同行们的工资,生活工作中的酸甜苦辣,谋求程序员的最终出路!

 价值13000svip视频教程,前端大神匠心打造,零基础前端开发工程师视频教程全套,基础+进阶+项目实战,包含课件和源码

  出租广告位,需要合作请联系站长


+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

暂无数据

::webkit 滚动条产生不同大小的滚动条

发布于2021-10-23 03:23     阅读(618)     评论(0)     点赞(8)     收藏(4)


这是我创建的用于重现我的表的代码笔:

https://codepen.io/NazariyV/pen/OoVdWq

出于某种原因,水平和垂直滚动条的大小不同,我不太明白为什么。我也试过这个,它根本没有被接受(即使我在源代码中看到,它使用了正确的 .css 文件):

.style-2::-webkit-scrollbar:horizontal
{
    width: 12px!important;
}

代码笔 HTML:

<div class="results-container">

        <div class="header">
            <p class="header-description">Filtered Results</p>
            <span class="additional-description"></span>
            <hr class="underline style-two"/>
        </div>

        <div id="table-scroll" class="table-scroll style-2">
            <table>
                <thead>
                    <tr>
                        <th scope="col">Assets</th>
                        <th scope="col">Weights</th>
                        <th scope="col">Weights</th>
                        <th scope="col">Weights</th>
                        <th scope="col">Weights</th>
                        <th scope="col">Weights</th>
                        <th scope="col">Weights</th>
                        <th scope="col">Weights</th>
                        <th scope="col">Weights</th>
                        <th scope="col">Weights</th>
                        <th scope="col">Weights</th>
                        <th scope="col">Weights</th>
                        <th scope="col">Weights</th>
                        <th scope="col">Weights</th>
                        <th scope="col">Weights</th>
                        <th scope="col">Weights</th>
                        <th scope="col">Weights</th>
                        <th scope="col">Weights</th>
                    </tr>
                </thead>
                <tbody>
                        <tr>
                            <th>Asset 1</th>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                        </tr>
                <tr>
                            <th>Asset 1</th>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                        </tr>
                <tr>
                            <th>Asset 1</th>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                        </tr>
                <tr>
                            <th>Asset 1</th>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                        </tr>
                <tr>
                            <th>Asset 1</th>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                        </tr>
                <tr>
                            <th>Asset 1</th>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                        </tr>
                <tr>
                            <th>Asset 1</th>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                        </tr>
                <tr>
                            <th>Asset 1</th>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                        </tr>
                <tr>
                            <th>Asset 1</th>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                        </tr>
                <tr>
                            <th>Asset 1</th>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                        </tr>
                <tr>
                            <th>Asset 1</th>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                        </tr>
                <tr>
                            <th>Asset 1</th>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                        </tr>
                <tr>
                            <th>Asset 1</th>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                        </tr>
                <tr>
                            <th>Asset 1</th>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                        </tr>
                <tr>
                            <th>Asset 1</th>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                        </tr>
                <tr>
                            <th>Asset 1</th>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                        </tr>
                <tr>
                            <th>Asset 1</th>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                        </tr>
                <tr>
                            <th>Asset 1</th>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                        </tr>
                <tr>
                            <th>Asset 1</th>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                            <td>0.2</td>
                        </tr>
                </tbody>
            </table>
        </div>

    </div>

代码笔 CSS:

html {
  box-sizing: border-box;
}
*,
*:before,
*:after {
  box-sizing: inherit;
}

.results-container {
    text-align: left;

    width: 85%;
    height: 400px;
    display: block;
    margin: 0 auto;
    margin-top: 60px;

    background: #ffffffb8;
    border-radius: 2px;

    box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
    transition: all 0.3s cubic-bezier(.25,.8,.25,1);
}

.results-container:hover {
    box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22);
}

.header-description {
    margin: 0;
    display: inline;
    margin-right: 250px;
    position: relative;
    left: 20px;
}

.additional-description {
    margin: 0;
}

.underline {
    margin-top: 2px;
}

.header {
    position: relative;
    top: 20px;
}

.style-2::-webkit-scrollbar-track
{
    -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
    border-radius: 10px;
    background-color: #F5F5F5;
}

.style-2::-webkit-scrollbar
{
    width: 12px;
    background-color: #F5F5F5;
}

.style-2::-webkit-scrollbar:horizontal
{
    width: 12px!important;
}

.style-2::-webkit-scrollbar-thumb
{
    border-radius: 10px;
    -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,.3);
    background-color: #F4F7F7;
}

/* ---------- Risk Scenarios Table ------------- */

.table-scroll {
  position: relative;
  min-width: 730px;
  z-index: 1;
  margin: 35px 20px 0px 15px;
  overflow: scroll;
  height: 325px;
}

.table-scroll table {
  min-width: 1280px;
}

.table-wrap {
  position: relative;
}

.table-scroll th,
.table-scroll td {
  padding: 5px 10px;
  background: #fff;
  vertical-align: top;
}

#table-scroll thead th {
  color: #333;
  border-bottom: 1px solid black;
  position: -webkit-sticky;
  position: sticky;
  top: 0;
}

.table-scroll tfoot,
.table-scroll tfoot th,
.table-scroll tfoot td {
  position: -webkit-sticky;
  position: sticky;
  bottom: 0;
  background: #666;
  color: #fff;
  z-index:4;
}

.table-scroll table th:first-child {
  position: -webkit-sticky;
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fff;
}

.table-scroll thead th:first-child,
.table-scroll tfoot th:first-child {
  z-index: 5;
}

body {
    font-family: 'Roboto', sans-serif;
}

/* ---------------------------------------- HR STYLES ----------------------------------------------------------------*/

hr.style-two {
    border: 0;
    height: 1px;
    background-image: linear-gradient(to right, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0));
}

hr.style-four {
    height: 12px;
    border: 0;
    box-shadow: inset 0 12px 12px -12px rgba(0, 0, 0, 0.5);
}

/* Custom Outline for Bootstrap drop downs (form control) */
.form-control:focus {
    border-color: #e5382d;
    box-shadow: 0 0 0 0.2rem rgba(167, 67, 70, 0.25);
    outline: 0;
}

请注意,我也在那里使用引导程序: https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css.


解决方案


我想通了,对于水平滚动条,您必须设置height

将此 CSS 添加到您的:

.style-2::-webkit-scrollbar {
  width: 12px;
  height: 12px;
  background-color: #F5F5F5;
}

简单的例子:

.outer {
  margin: 50px auto;
  padding: 5px;
  width: 300px;
  height: 300px;
  border: 1px solid red;
  overflow: scroll;
}
.inner {
  width: 600px;
  height: 600px;
  background: aqua;
}
.outer::-webkit-scrollbar-track {
  -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
  -moz-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
  -ms-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
  -o-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
  box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
  border-radius: 10px;
  background-color: #F5F5F5;
}
.outer::-webkit-scrollbar {
  width: 12px;
  height: 12px;
  background-color: #F5F5F5;
}
.outer::-webkit-scrollbar-thumb {
  border-radius: 10px;
  -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,.3);
  -moz-box-shadow: inset 0 0 6px rgba(0,0,0,.3);
  -ms-box-shadow: inset 0 0 6px rgba(0,0,0,.3);
  -o-box-shadow: inset 0 0 6px rgba(0,0,0,.3);
  box-shadow: inset 0 0 6px rgba(0,0,0,.3);
  background-color: #F4F7F7;
}
<div class="outer">
  <div class="inner">
    asdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasd
  </div>
</div>




所属网站分类: 技术文章 > 问答

作者:黑洞官方问答小能手

链接:http://www.qianduanheidong.com/blog/article/208441/74164f26d4cb63f65602/

来源:前端黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

8 0
收藏该文
已收藏

评论内容:(最多支持255个字符)