实现layer弹出iframe层隐藏滚动条,改变滚动条样式

项目单独使用的是layui的layer,要求弹出一个滚动框浏览界面,使用弹出iframe层。

但是原样式的滚动条实在是很难看,不符合界面要求,所以百度加自己结合写了一个。

一般来说,使用了layer.open中的scrollbar,设置为false的话,的确是没有滚动条了,但是页面也不能下拉了。

目的是为了改变滚动条样式,我使用的是隐藏了iframe层的滚动条,再内置一个滚动框,必须保证宽度一致

html代码:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title></title>
    </head>
        <script type="text/javascript" src="js/jquery.js" ></script>
        <script type="text/javascript" src="js/layer.js" ></script>
        <script>
            var Test2 = {
                init:function(){//入口
                    this.initNode();
                    this.bindEvent();
                },
                initNode:function(){//初始化节点
                    this.$test1 = $('#test1');
                },
                bindEvent:function(){//绑定事件
                    this.$test1.on('click',this.bigEvent);
                },
                tabEvent:function(){
                  layer.tab({
                  area: ['200px', '300px'],
                  tab: [{
                    title: 'TAB1', 
                    content: $('#table').html()
                  }, {
                    title: 'TAB2', 
                    content: '内容2'
                  }]
                })
                },
                bigEvent:function(){
                layer.open({
                  type: 2,
                  title: false,
                  resize:true,//禁止拖拉框的大小
                  area:['213px','400px'],
                  offset:['250px','100px'],
                  closeBtn: 0,
                  shadeClose: true,
//                  skin: ['demo-class','inner'],
//                  scrollbar:false,//关闭滚动条
                  content: ['http://127.0.0.1:8020/Layer/data.html?__hbt=1517449124311','no']
//                  content: 'http://127.0.0.1:8020/Layer/data.html?__hbt=1517449124311'
                })
                }
            };
            
            $(function() {
                Test2.init();
            });
        </script>
    <body style="width: 1000px;height: 800px;">
        

        <a id="test1" class="layui-btn layui-btn-primary" href="javascript:;">弹出</a>
        
    </body>
</html>

引入界面html:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <link rel="stylesheet" href="css/scroll.css" />
        </style>
    </head>
    <body>
        <div class="inner innerbox">
            <p>
                <span class="float_left span4">8750元/吨</span><br />
                <span class="float_left span4">100吨</span><span>线下</span><br />
                <span class="float_left span5">成交</span>
                <button style="float: right;background-color: red;margin: 0px;">成交</button>
              </p>
            <p>
                <span class="float_left span4">8750元/吨</span><br />
                <span class="float_left span4">100吨</span><span>线下</span><br />
                <span class="float_left span5">成交</span>
                <button style="float: right;background-color: red;margin: 0px;">成交</button>
              </p>
            <p>
                <span class="float_left span4">8750元/吨</span><br />
                <span class="float_left span4">100吨</span><span>线下</span><br />
                <span class="float_left span5">成交</span>
                <button style="float: right;background-color: red;margin: 0px;">成交</button>
              </p>
            <p>
                <span class="float_left span4">8750元/吨</span><br />
                <span class="float_left span4">100吨</span><span>线下</span><br />
                <span class="float_left span5">成交</span>
                <button style="float: right;background-color: red;margin: 0px;">成交</button>
              </p>
            <p>
                <span class="float_left span4">8750元/吨</span><br />
                <span class="float_left span4">100吨</span><span>线下</span><br />
                <span class="float_left span5">成交</span>
                <button style="float: right;background-color: red;margin: 0px;">成交</button>
              </p>
            <p>
                <span class="float_left span4">8750元/吨</span><br />
                <span class="float_left span4">100吨</span><span>线下</span><br />
                <span class="float_left span5">成交</span>
                <button style="float: right;background-color: red;margin: 0px;">成交</button>
              </p>
            <p>
                <span class="float_left span4">8750元/吨</span><br />
                <span class="float_left span4">100吨</span><span>线下</span><br />
                <span class="float_left span5">成交</span>
                <button style="float: right;background-color: red;margin: 0px;">成交</button>
              </p>
            <p>
                <span class="float_left span4">8750元/吨</span><br />
                <span class="float_left span4">100吨</span><span>线下</span><br />
                <span class="float_left span5">成交</span>
                <button style="float: right;background-color: red;margin: 0px;">成交</button>
              </p>
            <p>
                <span class="float_left span4">8750元/吨</span><br />
                <span class="float_left span4">100吨</span><span>线下</span><br />
                <span class="float_left span5">成交</span>
                <button style="float: right;background-color: red;margin: 0px;">成交</button>
              </p>
            <p>
                <span class="float_left span4">8750元/吨</span><br />
                <span class="float_left span4">100吨</span><span>线下</span><br />
                <span class="float_left span5">成交</span>
                <button style="float: right;background-color: red;margin: 0px;">成交</button>
              </p>
            <p>
                <span class="float_left span4">8750元/吨</span><br />
                <span class="float_left span4">100吨</span><span>线下</span><br />
                <span class="float_left span5">成交</span>
                <button style="float: right;background-color: red;margin: 0px;">成交</button>
              </p>
        </div>
    </body>
</html>

 

CSS:

.inner{
            width: 200px;
            height: 400px;
            position: absolute;
            top: 33px;
            left: 13px;
            /*cursor: pointer;*/
            overflow:hidden;
        }
        .innerbox{
            overflow-x: hidden;
            overflow-y: auto;
            color: #000;
            font-size: .7rem;
            font-family: "\5FAE\8F6F\96C5\9ED1",Helvetica,"黑体",Arial,Tahoma;
            height: 100%;
        }
        /*滚动条样式*/
        .innerbox::-webkit-scrollbar {/*滚动条整体样式*/
            width: 4px;     /*高宽分别对应横竖滚动条的尺寸*/
            height: 4px;
        }
        .innerbox::-webkit-scrollbar-thumb {/*滚动条里面小方块*/
            border-radius: 5px;
            -webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
            background: rgba(0,0,0,0.2);
        }
        .innerbox::-webkit-scrollbar-track {/*滚动条里面轨道*/
            -webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
            border-radius: 0;
            background: rgba(0,0,0,0.1);
        }

 

转载于:https://www.cnblogs.com/zhengyuanyuan/p/8397846.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值