最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

jQuery實(shí)現(xiàn)頁面滾動(dòng)時(shí)層智能浮動(dòng)定位實(shí)例探討

 更新時(shí)間:2013年03月29日 18:04:35   作者:  
在博客或者微博上面也會見到這個(gè)效果,所以客戶就也想要這樣的效果了,接下來為大家詳細(xì)介紹下浮動(dòng)定位實(shí)現(xiàn)的過程,感興趣的朋友可以參考下哈
各位兄弟可能碰到定位的問題,特別是在博客或者微博上面也會見到這個(gè)效果,于是產(chǎn)品人員在策劃的時(shí)候就會要人家那種效果,,,而苦逼的我們需要去實(shí)現(xiàn),實(shí)現(xiàn)實(shí)現(xiàn)。。。。。沒辦法,誰讓我們是攻城師呢,攻吧:

效果圖如下,滾動(dòng)條下拉的時(shí)候黑色的塊TOP為0;固定顯示:

代碼如下:
復(fù)制代碼 代碼如下:

<!DOCTYPE html>
<html >
<head>
<title>jQuery實(shí)現(xiàn)頁面滾動(dòng)時(shí)層智能浮動(dòng)定位</title>
<meta name="description" content="" />
<script type="text/javascript" src="http://jt.875.cn/js/jquery.js"></script>
<style type="text/css">
*{ margin:0; padding:0;}
.top{height:100px; background:#ccc;text-align:center; line-height:100px; font-size:40px;}
body { font:12px/1.8 Arial; color:#666; height:2000px;}
.float{width:200px; height:200px; border:1px solid #ffecb0; background-color:#000;position:absolute; right:10px; top:150px;}
</style>
</head>
<body>
<div class="top">導(dǎo)航啊導(dǎo)航啊導(dǎo)航</div>
<div class="float" id="float"></div>
<script type="text/javascript">
$.fn.smartFloat = function() {
var position = function(element) {
var top = element.position().top, pos = element.css("position");
$(window).scroll(function() {
var scrolls = $(this).scrollTop();
if (scrolls > top) {
if (window.XMLHttpRequest) {
element.css({
position: "fixed",
top: 0
});
} else {
element.css({
top: scrolls
});
}
}else {
element.css({
position: pos,
top: top
});
}
});
};
return $(this).each(function() {
position($(this));
});
};
//綁定
$("#float").smartFloat();
</script>
</div>
</body>
</html>

相關(guān)文章

最新評論

齐河县| 信阳市| 宜兴市| 甘孜| 扎鲁特旗| 城步| 德安县| 洮南市| 临安市| 永福县| 惠水县| 浦县| 盱眙县| 泗水县| 曲松县| 浠水县| 平乡县| 卢氏县| 孟津县| 新闻| 青海省| 泽州县| 福清市| 友谊县| 通榆县| 茂名市| 永昌县| 兰西县| 台北市| 阿克陶县| 成都市| 嘉禾县| 桐梓县| 梅河口市| 肥城市| 关岭| 铁力市| 南丰县| 防城港市| 绵阳市| 姜堰市|