关于圣杯布局、双飞翼布局、Flex布局和绝对定位布局的几种经典布局的具体实现示例

博客提及转载地址,重点是博主自己实现的圣杯布局代码,圣杯布局是前端开发中常见的布局方式,此代码可用于前端页面的布局设计。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

转载地址:

https://blog.youkuaiyun.com/wangchengiii/article/details/77926868

自己实现的圣杯布局代码

<!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-right: -100%;
			/*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>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值