zoukankan      html  css  js  c++  java
  • 如何使用CSS隐藏滚动条并且兼容大部分浏览器

    隐藏滚动条,已经自己实测在浏览器Chrome, IE (6+), Firefox, Opera, Safari。

    如下demo:

    Content 1
    Content 1
    Content 1
    Content 1
    Content 1
    Content 1
    Content 1
    Content 1
    Content 1
    Content 1
    Content 1
    Content 1
    Content 1
    Content 1
    Content 1
    Content 1
    Content 1
    Content 1
    Content 1
    Content 1
    Content 1
    Content 1
    Content 1
    Content 1
    Content 1
    Content 1
    Content 1
    Content 1
    Content 1
    Content 1
    <html>
    <head>
        <style>
            .element,
            .outer-container {
                width: 200px;
                height: 200px;
            }
    
            .outer-container {
                /* border: 5px solid purple; */
                position: relative;
                overflow: hidden;
            }
    
            .inner-container {
                position: absolute;
                left: 0;
                overflow-x: hidden;
                overflow-y: scroll;
            }
    
            .inner-container::-webkit-scrollbar {
                 display: none; 
            }
        </style>
    </head>
    <body>
        <div class="outer-container">
            <div class="inner-container">
                <div class="element">
                    <div>Content 1</div>
                    <div>Content 1</div>
                    <div>Content 1</div>
                    <div>Content 1</div>
                    <div>Content 1</div>
                    <div>Content 1</div>
                    <div>Content 1</div>
                    <div>Content 1</div>
                    <div>Content 1</div>
                    <div>Content 1</div>
                    <div>Content 1</div>
                    <div>Content 1</div>
                    <div>Content 1</div>
                    <div>Content 1</div>
                    <div>Content 1</div>
                    <div>Content 1</div>
                    <div>Content 1</div>
                    <div>Content 1</div>
                    <div>Content 1</div>
                    <div>Content 1</div>
                    <div>Content 1</div>
                    <div>Content 1</div>
                    <div>Content 1</div>
                    <div>Content 1</div>
                    <div>Content 1</div>
                    <div>Content 1</div>
                    <div>Content 1</div>
                    <div>Content 1</div>
                    <div>Content 1</div>
                    <div>Content 1</div>
                </div>
            </div>
        </div>
    </body>
    </html>

    参见:https://blogs.msdn.microsoft.com/kurlak/2013/11/03/hiding-vertical-scrollbars-with-pure-css-in-chrome-ie-6-firefox-opera-and-safari/

  • 相关阅读:
    MyBatis 数据库字段排序问题(一)
    MySQL 函数
    Google 浏览器设置打开超链接到新窗口标签页
    Linux 命令整理 vim
    IDEA比较实用的插件之翻译插件(Translation)
    Dubbo-本地Bean测试
    Spring+dubbo错误(二)
    Spring+dubbo错误(一)
    Dubbo-本地测试直连
    上架app被拒原因总结
  • 原文地址:https://www.cnblogs.com/fangsmile/p/7390106.html
Copyright © 2011-2022 走看看