亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

div固定在頂部的時候,滾動滾動條會閃爍

div固定在頂部的時候,滾動滾動條會閃爍

慕村1106498 2017-09-01 17:21:36
代碼:<!DOCTYPE html><html><head>?? ?<meta charset="utf-8">?? ?<title></title>?? ??? ?<script src="jq.js"></script></head><style type="text/css">?? ?.wrap{margin: 0 auto;border: 1px solid #ccc;width: 1000px;height: 500px;margin-top: 500px;margin-bottom: 1000px;}?? ?.left{width: 100px;height: 200px;margin: 5em;border: 1px solid #ccc;}</style><body><div>?? ?<div>?? ??? ?往下滾動把?? ?</div></div><script type="text/javascript">?? ?$(document).ready(function(){?? ??? ?$(window).scroll(function(){?? ??? ??? ?if(parseInt($(".wrap .left").offset().top)+parseInt($(".wrap .left").css('height'))/3 < $(window).scrollTop())?? ??? ??? ?{?? ??? ??? ??? ?//獲取div距離?? ??? ??? ??? ?var left = $(".wrap .left").offset().left;?? ??? ??? ??? ?$(".wrap .left").css({position:"fixed",'left':left-$(".wrap .left").css('width'),top:0});?? ??? ??? ??? ??? ??? ??? ?}else{?? ??? ??? ??? ?$(".wrap .left").css({position:"relative"});?? ??? ??? ?}?? ??? ??? ?// if(parseInt($(".wrap .left").offset().top)+parseInt($(".wrap .left").css('height')) > $(window).scrollTop()){?? ??? ??? ?// ?? ?$(".left").css({position:"relative"});?? ??? ??? ?// }?? ??? ?});?? ?});</script></body></html>不知道為什么每次滾動條滾動的時候div就會閃爍。我想做一個滾動到div的時候就固定在頂部位置,否則就回到原來的位置不動
查看完整描述

1 回答

?
牛奶老哥哥

TA貢獻204條經驗 獲得超92個贊

…既然解決了…介不介意給個采納(,,?ω?,,)

查看完整回答
反對 回復 2017-09-01
  • 1 回答
  • 1 關注
  • 3574 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號