前端

 
百度地图第三方接口pc端的地址:

http://map.baidu.com/?latlng=34.507327,109.479665&title=标题&content=介绍&autoOpen=true&l

实现html的table滚动条,根据table的高度和宽度进行自适应,html标签如下:

<div class="result_wrap">
         <!-- BEGIN PORTLET-->

         <div style="height: 20px; overflow: hidden; overflow-x: scroll; position: fixed; bottom: 0px; z-index: 1000;">
        <div id="customerScrollBody" style="height: 100px;"></div>
         </div>

       <div style="overflow-x: scroll; ">

        <table class="result" style="margin-bottom: 0px; width: 100% !important;" id="customerList">
          
       </table>
</div>

js代码是这样的,直接用就可以:

 // 处理滚动。
    var $customerScrollBody = $('#customerScrollBody');
    var $customerList = $('#customerList');
    var $customerScrollBodyParent = $customerScrollBody.parent()
    var $customerListParent = $customerList.parent();
    var $window = $(window);
    $window.resize(function() {
        $customerScrollBodyParent.width($customerListParent.width());
        $customerScrollBody.width($customerList.width());
        $window.trigger('scroll');
    }).trigger('resize');
    $window.scroll(function() {
        var scrollTop = $window.scrollTop();
        var clientHeight = document.documentElement.clientHeight > 0 ? document.documentElement.clientHeight : document.body.clientHeight;
        var offsetTop = $customerList.offset().top;
        var outerHeight = $customerListParent.outerHeight();
        if ((offsetTop + outerHeight) > (scrollTop + clientHeight)) {
            $customerScrollBodyParent.show();
            $customerScrollBodyParent.scrollLeft($customerListParent.scrollLeft());
        }
        else {
            $customerScrollBodyParent.hide();
        }
    }).trigger('scroll');
    $customerScrollBodyParent.scroll(function() {
        $customerListParent.scrollLeft($customerScrollBodyParent.scrollLeft());
    });

 

转载于:https://my.oschina.net/u/3482593/blog/1540924

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值