一招秒杀常见网页基本排版布局

第一种HTML CSS使用div(盒子)进行基本布局

1.单列布局

      网页分为上中下三个模块

​
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>网页上中下</title>
        </head>
        <style>
            body{
                margin: 0;
            }
            .box{
                width: 960px;margin: 0 auto;
            }
            .box .header{
                height: 120px;
                border: 1px solid #0000FF;
                line-height: 120px;
            }
            .box .main{
                height: 300px;
                border: 1px solid #00FF00;
                line-height: 300px;
            }
            .box .footer{
                height: 100px;
                border: 1px solid red;
                line-height: 100px;
            }
            p{
                text-align: center;
            }
        </style>
    
    <body>
        <div class="box">
            <p class="header">头部</p>
            <p class="main">主题</p>
            <p class="footer">底部</p>
        </div>
    </body>
</html>

​

2.双列布局

网页分为左右模块

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>网页左右布局(双列布局)</title>
		</head>		
		<style>
			body{
				margin: 0;
			}
			.box{
				width: 80%;
				margin: 0 auto;
				overflow: hidden;
			}
			.box .left{
				width: 30%;
				height: 400px;
				background-color: #0f0;
				float: left;
			}
			.box .right{
				width: 70%;
				height: 400px;
				background-color: #0000FF;
				float: left;
			}
		</style>	
	<body>
		<div class="box">
			<p class="left">1</p>
			<p class="right">2</p>
		</div>
	</body>
</html>

3.三列布局

网页分为左中右模块

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>三列布局</title>
		<style>
			body{
				margin: 0;
			}
			.box{
				width: 960px;
				margin: 0 auto;
				position: relative;
			}
			.box .left{
				width: 200px;
				height: 400px;
				background-color: #FF0000;
				position: absolute;
			}
			.box .center{
				height: 400px;
				background-color: #00FF00;
				margin:0 300px 0 200px;
				position: relative;
				margin-top: 10px;
				
				
			}
			.box .right{
				width: 300px;
				height: 400px;
				background-color: #FFC0CB;
				position: absolute;
				right: 0;top: 0;
			}
		</style>
	</head>
	<body>
		<div class="box">
			<p class="left">左</p>
			<p class="center">中</p>
			<p class="right">右</p>
		</div>
	</body>
</html>

4.混合布局(常见网页布局) 

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>混合布局</title>
		<style>
			body{
				margin: 0;
			}
			.box{
				width: 960px;margin: 0 auto;
			}
			.header{
				height: 120px;background-color: #ddd;
			}
			.main{
				height: 400px;background-color: #f00;
				position: relative;
			}
			.main .left{
				width: 200px;height: 400px;position: absolute;
				left: 0;top: 0;
				background-color: #ofccaa;
			}
			.main .center{
				height: 400px;margin: 0 300px 0 205px;
				background-color: #123456;
			}
			.main .right{
				width: 300px;height:400px;
				position: absolute;
				right: 0;top: -16px;
				background-color: #ff0;
			}
			.footer{
				height: 80px;
				background-color: blue;
			}
		</style>
	</head>
	<body>
		<div class="box">
			<div class="header">头部</div>
			<div class="main">
					<p class="left">嵌套内容左部分</p>
					<p class="center">嵌套内容中间</p>
					<p class="right">嵌套内容右部分</p>
			</div>	
			<div class="footer">底部</div>
		</div>
	</body>
</html>

 

  • 8
    点赞
  • 75
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值