国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > CSS > 正文

css實現(xiàn)網頁欄目左側固定當滾動到底部時自動調整位置

2024-07-11 09:00:02
字體:
來源:轉載
供稿:網友

預覽地址:

https://ovsexia.gitee.io/leftfixed/

html:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><script src="js/jquery-1.10.1.min.js" type="text/javascript"></script><link href="css/layout.css" type="text/css" rel="stylesheet" /><link href="css/style.css" type="text/css" rel="stylesheet" /></head><div class="top"></div><div class="page">  <div class="left">    <div class="left_poi"></div>    <div class="left_in">      <p><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /></p>    </div><!--left_in-->    <script>    $(window).scroll(function()    {        saction();    });    function saction()    {        sj = 20; //底部間隔        st = $(window).scrollTop(); //滾動條高度        sd = $(".left_poi").offset().top;        sd_h = $(".left_in").height();        sb = $(".bottom").offset().top;        sb_h = $(".bottom").height();        rd_h = $(".right").height();        bh = window.innerHeight;        si = sb-sd_h;        if(st>sd && rd_h>=sd_h){            $(".left_in").addClass("on");            if(st>si){                sy = bh-(sb-st)+sj;                $(".left_in").css({"top":"auto","bottom":sy+"px"});            }else{                $(".left_in").css({"top":"","bottom":""});            }        }else{            $(".left_in").removeClass("on");        }    }    </script>  </div><!--left-->  <div class="right"></div>  <div class="clear"></div></div><!--page--><div class="bottom"></div></body></html>

css

@charset "utf-8";.clear {clear:both; height:0 !important; width:0 !important; overflow:hidden; font-size:0;}.top {width:100%; height:150px; background:#0CC;}.bottom {width:100%; height:400px; background:#39C;}.page {width:1200px; margin:20px auto; position:relative;}.left {width:200px; float:left;}.left_in {width:200px; background:#46bc67; border-top:3px solid #000; border-bottom:3px solid #000;}.left_in.on {position:fixed; top:0;}.left_poi {width:100%; height:1px; overflow:hidden;}.right {width:960px; height:2100px; float:right; overflow:hidden; background:#FC3;}

總結

以上所述是小編給大家介紹的css實現(xiàn)網頁欄目左側固定當滾動到底部時自動調整位置 ,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對武林網網站的支持!

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 广西| 乐安县| 郯城县| 会宁县| 招远市| 台前县| 平果县| 宁强县| 九江县| 双牌县| 浏阳市| 嘉兴市| 重庆市| 牙克石市| 普宁市| 南乐县| 图们市| 青岛市| 永善县| 五河县| 神木县| 高州市| 镇雄县| 平塘县| 河池市| 垣曲县| 三都| 大关县| 安义县| 汪清县| 名山县| 东丰县| 称多县| 嘉兴市| 本溪市| 常德市| 达拉特旗| 浪卡子县| 沅陵县| 枞阳县| 枝江市|