DIV自适应页面宽度的实现

来源:互联网 发布:als矩阵分解推荐模型 编辑:程序博客网 时间:2024/05/17 02:48
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>DIV自适应页面宽度的实现</title>
<style type="text/css">
<!--
div {
 height: 5em;
 line-height: 5em;
 text-align: center;
 margin: 0;
 padding: 0;
}
#div1, #div3, #div4, #div6 {
 float: left;
 background: #CCC;
}
#div1 {
 width: 20%;
}
#div2 {
 float: left;
 width: 30%;
 background: red;
}
#div3 {
 width: 50%;
}
#div4 {
 width: 200px;
 margin-right: -3px;
}
#div5 {
 background: red;
 line-height: 1.4em;
 text-align: left;
}
#div6 {
 width: 300px;
 float: right;
 margin-left: -3px;
}
div[id="div4"] {
 margin-right: 0 !important;
}
div[id="div6"] {
 margin-left: 0 !important;
}
-->
</style>
</head>

<body>
<h2>百分比宽度</h2>
<div id="div1">20%</div>
<div id="div2">30%</div>
<div id="div3">50%</div>
<h2>DIV自适应页面宽度的实现</h2>
<div id="div4">left:200px</div>
<div id="div6">right:300px</div>
<div id="div5">DIV自适应页面宽度的实现</div>
</body>
</html>

 

原创粉丝点击