像淘宝里 商品详情 那条选项卡超过了高度都自动跟随的代码
效果如图
效果地址:http://detail.tmall.com/item.htm?spm=a2106.m895.1000384.d11.Jjhd6L&id=20503104378&source=dou&scm=1029.newlist-0.bts7.50011131&ppath=谢谢
效果如图
效果地址:http://detail.tmall.com/item.htm?spm=a2106.m895.1000384.d11.Jjhd6L&id=20503104378&source=dou&scm=1029.newlist-0.bts7.50011131&ppath=谢谢
function AgreeSubmit(doc) {
if (doc && doc.type.toLowerCase() == "checkbox") {
var btn = document.getElementById(doc.id.replace('checkboxagree', 'btnsubmit'));
if (btn && btn.type.toLowerCase() == "button") {
if (doc.checked) { btn.className = "btn100"; }
else { btn.className = "btn100_2"; }
btn.disabled = !doc.checked;
}
}
}这里模仿的不错
http://www.hellbear.com/app/list.htmlhttp://www.hellbear.com/app/list.html
#scs{
border: 1px solid red;
height:20px;
font:12px/25px "宋体";
width:500px;
}
</style>
<div style="height:200px"></div>
<div id="scs">这是固定的</div>
<div style="height:2000px"></div>
<script type="text/javascript">
window.onload=function(){
var scs=document.getElementById("scs");//获取对象
var t=scs.offsetTop;//获得本身到网页顶部的距离
var isIE6 = !-[1,] && !window.XMLHttpRequest;//判断ie6
var i=0;
window.onscroll=function(){
i=document.documentElement.scrollTop;
if(i>t){
//网页被卷去的高大于本身到网页顶部的距离(简单理解就是对象开始要被卷到网页顶部不可视区域)
if(isIE6){
scs.style.position="absolute";
scs.style.top=i+"px";
}else{
scs.style.position="fixed";
scs.style.top=0;
}
}else{
scs.style.position="static";
scs.style.top="auto";
}
}
}
</script>