欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

html 左中右自適應(yīng)布局(使用calc css表達(dá)式)

  發(fā)布時(shí)間:2013-06-13 17:19:02   作者:佚名   我要評(píng)論
在最新的html標(biāo)準(zhǔn)中 有了個(gè)calc css表達(dá)式,我們可以用這個(gè)來(lái)計(jì)算布局。但是在古老的IE中,卻不支持,為了所有瀏覽器的支持,下面與大家分享下使用js來(lái)解決不支持的問題
在最新的html標(biāo)準(zhǔn)中 有了個(gè)calc css表達(dá)式,我們可以用這個(gè)來(lái)計(jì)算布局。
但是在古老的IE中,卻不支持,為了所有瀏覽器的支持,這里用了js來(lái)做。
截圖:
 
code:

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

<!DOCTYPE HTML PUBLIC "-//IETF//DTD LEVEL1//EN">
<html>
<head>
<title>MyHtml.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script>
var left,center,right,width;
window.onload=function(){
left=$('left');
center=$('center');
right=$('right');
onresize();
};
window.onresize=function(){
try {
width = document.body.clientWidth;
center.style.width = (width - left.clientWidth - right.clientWidth - 0) + "px";
}catch(e){
//小于0會(huì)報(bào)錯(cuò)
}
};
function $(id){
return document.getElementById(id);
}
</script>
<style>
body,html{
height:100%;
margin:0px;
padding:0px;
overflow:hidden;
}
#left,#center,#right{
width:200px;
height:100px;
background-color:rgb(34,124,134);
float:left;
height:100%;
}
#center{
background-color:red;
}
</style>
</head>
<body>
<div id="left"></div>
<div id="center"></div>
<div id="right"></div>
</body>
</html>

相關(guān)文章

最新評(píng)論