function SetWidth(){
var bodyWidth = parseInt(document.body.offsetWidth);
var body_div=document.getElementById("body_div");
var cont_div_right=document.getElementById("content_div_right");
if(bodyWidth>600){
body_div.style.width=(bodyWidth-20)+"px";
body_div.style.margin="auto";
body_div.style.border="1px solid pink";
cont_div_right.style.width=(bodyWidth-20-300)+"px";
}else{
body_div.style.width=(600-20)+"px";
cont_div_right.style.width=(600-20-300)+"px";
}
}
window.onresize=function(){
SetWidth();
}
window.onload=function(){
SetWidth();
}
上面是JavaScript,下面是html
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)