zblog,wordpress建站源码,探路者OZHO.cn

zblog,wordpress建站源码,探路者OZHO.cn

Z-Blog PHP zblog固定#divSidebar模块

 #divSidebar
{
position:sticky;
top: 3px;
left: 10px;

}
#divMain{
    width:720px;
    margin:10px 0 0 0;
    padding:0 0 30px 10px;
    text-align:left;
    float:left;height:1834px;

}
<script language="”javascript”">function $(id) {
return document.getElementById(id);
}

window.onload = function () {
var img1 = $(“#divSidebar”);

var imgTop = img1.offsetTop;//保留最初的位置
window.onscroll = function () {
img1.style.top = (parseInt(imgTop) + parseInt(ScollPostion().top)) + “px”;//将现在的位置更为为最初位置加上滚动条距上面的距离

};
}
function ScollPostion() {//获得滚动条信息
var t, l, w, h;
if (document.documentElement && document.documentElement.scrollTop) {
t = document.documentElement.scrollTop;
l = document.documentElement.scrollLeft;
w = document.documentElement.scrollWidth;
h = document.documentElement.scrollHeight;
} else if (document.body) {
t = document.body.scrollTop;
l = document.body.scrollLeft;
w = document.body.scrollWidth;
h = document.body.scrollHeight;
}
return { top: t, left: l, width: w, height: h };
}

$(document).ready(function () {
var menuYloc = $(“#divSidebar”).offset().top;
$(window).scroll(function () {
var offsetTop = menuYloc + $(window).scrollTop() + “px”;
$(“#divSidebar”).animate({ top: offsetTop }, { duration: 60, queue: false });
}); <!–这里的queue是布尔值,是否一开始就执行动画,false就是一开始就执行;duration就是时间持续多久–>});</script>

zblog固定#divSidebar模块

上一篇:Z-Blog留言本

下一篇: Z-Blog搜索

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

网站分类
搜索
最新留言
    文章归档