网页局相关

1圣杯布局:浮动情况下,负边界值会导致DIV上移 如margin-left:-100px 或者margin-right:-100px    然后再使用left和right属性调整水平移动。

<div class="container">  

     <div>中间</div>

     <div>左侧</div>

    <div>右侧</div>

</div>


<!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 charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>圣杯布局</title>
    <style type="text/css">
        *{margin: 0;padding: 0;}
        body{min-width: 700px;}
        .header,
        .footer{
            border: 1px solid #333;
            background: #ddd;
            text-align: center;
            height: 40px;
            line-height: 40px;
        }
        .left,
        .middle,
        .right{
            position: relative;
            float: left;
            min-height: 130px;
        }
        .container{
            padding:0 220px 0 200px;
            overflow: hidden;
        }
        .left{
            margin-left: -100%;
            left: -200px;
            width: 200px;
            background: #f00;
        }
        .right{
            margin-left: -220px;
            right: -220px;
            width: 220px;
            background: #30a457;
        }
        .middle{
            width: 100%;
            background: #1a5acd;
            word-break: break-all;

        }
        .footer{
            clear: both;
        }
    </style>
</head>
<body>
<div class="header">
    <h4>header</h4>
</div>
<div class="container">
    <div class="middle">
        <h4>middle</h4>
        <p>
            这是页面的主体内容
            这是页面的主体内容
            这是页面的主体内容
            这是页面的主体内容
            这是页面的主体内容
            这是页面的主体内容
            这是页面的主体内容
            这是页面的主体内容
        </p>
    </div>
    <div class="left">
        <h4>left</h4>
        <p>
            这是页面的左边
            这是页面的左边
            这是页面的左边
            这是页面的左边
            这是页面的左边
            这是页面的左边
        </p>
    </div>
    <div class="right">
        <h4>right</h4>
        <p>
            这是页面的右边
            这是页面的右边
            这是页面的右边
            这是页面的右边
        </p>
    </div>
</div>
<div class="footer">
    <h4>footer</h4>
</div>
</body>
</html>





扫描二维码关注公众号,回复: 3213779 查看本文章

2.行布局:上下为0,左右居中 magin:0,auto  页面自适应:100%  {position:absolute; left:50% top:50% ;margin-left:-50% width; margin-top:-50% }


3.双飞翼布局:

<div class="main">

      <div>中间</div>

</div>

<div >左侧</div>

<div>右侧</div>

<!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 charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>双飞翼布局</title>
    <style type="text/css">
        *{margin: 0;padding: 0;}
        body{min-width: 700px;}
        .header,
        .footer{
            border: 1px solid #333;
            background: #ddd;
            text-align: center;
            height: 40px;
            line-height: 40px;
        }
        .sub,
        .main,
        .extra{
            float: left;
            min-height: 130px;
        }
        .sub{
            margin-left: -100%;
            width: 200px;
            background: #f00;
        }
        .extra{
            margin-left: -220px;
            width: 220px;
            background: #1a5acd;
        }
        .main{
            width: 100%;
        }
        .main-inner{
            margin-left: 200px;
            margin-right: 220px;
            min-height: 130px;
            background: #30a457;
            word-break: break-all;
        }
        .footer{
            clear: both;
        }
    </style>
</head>
<body>
<div class="header">
    <h4>header</h4>
</div>
<div class="main">
    <div class="main-inner">
        <h4>main</h4>
        <p>
            这是页面的主体内容
            这是页面的主体内容
            这是页面的主体内容
            这是页面的主体内容
            这是页面的主体内容
            这是页面的主体内容
            这是页面的主体内容
            这是页面的主体内容
        </p>
    </div>
</div>
<div class="sub">
    <h4>sub</h4>
    <p>
        这是页面的左边
        这是页面的左边
        这是页面的左边
        这是页面的左边
        这是页面的左边
        这是页面的左边
    </p>
</div>

<div class="extra">
    <h4>extra</h4>
    <p>
        这是页面的右边
        这是页面的右边
        这是页面的右边
        这是页面的右边
    </p>
</div>
<div class="footer">
    <h4>footer</h4>
</div>
</body>
</html>


猜你喜欢

转载自blog.csdn.net/apacheuk/article/details/78765160
今日推荐