宽度固定的三栏布局

效果图



html代码

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<link rel="stylesheet" href="css/style.css" /> 
	</head>
	<body>
		<div id="wrapper">
			<header>
				<h1>Fixed-Width Layout</h1> 
			</header>
			<nav>
				<div class="inner">
				<ul>
					<li>link1</li>
					<li>link2</li>
					<li>link3</li>
				</ul>		
				</div>
			</nav>
			<article>
				<div clas="inner">
				A telephone was ringing in the darkness—a tinny, unfamiliar ring.<br />
				He fumbled for the bedside lamp and turned it on.<br />
				Squinting at his surroundings he saw a plush Renaissance bedroom with Louis XVI furniture,
				 hand-frescoed walls, and a colossal mahogany four-poster bed.
				 A telephone was ringing in the darkness—a tinny, unfamiliar ring.<br />
				He fumbled for the bedside lamp and turned it on.<br />
				Squinting at his surroundings he saw a plush Renaissance bedroom with Louis XVI furniture,
				 hand-frescoed walls, and a colossal mahogany four-poster bed.
				 A telephone was ringing in the darkness—a tinny, unfamiliar ring.<br />
				He fumbled for the bedside lamp and turned it on.<br />
				Squinting at his surroundings he saw a plush Renaissance bedroom with Louis XVI furniture,
				 hand-frescoed walls, and a colossal mahogany four-poster bed.
				</div>
			</article>
			<aside>
				<div class="inner">
				<h2>This is aside</h2>
				He fumbled for the bedside lamp and turned it on.<br />
				Squinting at his surroundings he saw a plush Renaissance.
				</div>
			</aside>
			<footer>this is footer</footer>
		</div>
	</body>
</html>

css样式

*{
	margin: 0;
	padding: 0;
}
#wrapper{
	/*overflow: hidden;*/
	width: 960px;
	margin: 0 atuo;
	border: 1px solid;	
}

article{
	box-sizing: border-box;/*第三种方法*/
	background: #ffed53;
	width: 600px;
	float: left;
	padding: 10px;
}
nav{
	box-sizing: border-box;/*第三种方法*/
	width:150px ;
	float: left;
	background: #dcd9c0;
}

nav li{
	list-style-type: none;
}

aside{
	box-sizing: border-box;/*第三种方法*/
	width:210px;
	float: left;
	background: #3f7ccf;
}
header{
	background: #f00;
	text-align: center;
}
footer{
	background: #DCD9C0;
	clear: both;
	text-align: center;
}

/*.inner{	
	padding:10px;	
}*/


笔记:中间article栏增加padding和margin时,会造成右边的aside栏跑到下面,有两种解决办法。

1.给中间的内容增加一个div,改变这儿div的padding和margin

2.给三个块元素增加box-sizing:border-box







评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值