慕课笔记利用css进行布局【一列布局】

<html>
	<head>
		<title>一列布局</title>
		<style type="text/css">
			body{margin:0;padding:0;text-align:center}
			/*一列的布局样式*/
				/*margin:0 auto使div居中*/
			.top{width:800px;height:50px;background:#00f;margin:0 auto}
			.main{width:800px;height:250px;background:#ccc;margin:0 auto}
			.foot{width:800px;height:50px;background:#f00;margin:0 auto}
		</style>
	</head>
	<body>
	<!--/*一列的布局样式*/-->
	一列的布局样式<br/>
	<div class="top">一列布局01</div>
	<div class="main">一列布局02</div>
	<div class="foot">一列布局03</div>
	 <br/>
	 <br/>

	</body>
</html>

效果如下:

关键知识点:margin:0 auto使div居中

 
时间: 2024-07-29 03:41:13

慕课笔记利用css进行布局【一列布局】的相关文章

慕课笔记利用css进行布局【三列布局】

三个div中间自适应,两侧固定大小 <html> <head> <title>三列布局</title> <style type="text/css"> body{margin:0;padding:0;text-align:center} /*三列的布局样式*/ /*position:absolute定位*/ .left2{width:200px;height:500px;background:#f0f;position:abs

慕课笔记利用css进行布局【两列布局】

<html> <head> <title>两列布局</title> <style type="text/css"> body{margin:0;padding:0;text-align:center} /*两列的布局样式*/ /*float:left向左浮动*/ .content{width:920px;margin:0 auto} .left{width:20%;height:500px;background:#f00;fl

慕课笔记利用css进行布局【混合布局练习】

通过学习div的布局,以一个简单的内容管理网站的布局为例子,用div+css进行简单的网页布局,加深学印象: <html> <head> <title>CSS+div布局学习</title> <style type="text/css"> body{margin:0;padding:0;text-align:center} .head{height:230px;width:960px;background:#f96;margi

慕课笔记利用css进行布局【混合布局】

<html> <head> <title>混合布局学习</title> <style type="text/css"> body{margin:0;padding:0;text-align:center} .top{height:50px;background:#00f;margin:0 auto} .head{height:50px;width:700px;background:#f96;margin:0 auto} .ma

简单的CSS网页布局--一二列布局

1.一列布局 (一)一列自适应 自适应浏览器,随着浏览器的拉伸而变化,一般宽度采用百分比的写法,很简<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title>一列布局自适应</title> <style type="text/css"> body{ margin: 0; /*清除浏览

简单的CSS网页布局--三列布局

三列布局其实不难,不过要用到position:absolute这个属性,因为这个属性是基于浏览器而言,左右部分各放在左右侧,空出中间一列来实现三列布局. 1 <!DOCTYPE html> 2 <html> 3 <head lang="en"> 4 <meta charset="UTF-8"> 5 <title>三列自适应</title> 6 <style type="text/

css之页面两列布局

两列布局:左边固定,后边自适应 第一种方法:左边的div左浮动或者是绝对定位,右边的div加margin-left:左边div的宽度 html部分 <div class="left"></div> <div class="right"></div> css部分 .left { position: absolute; /*这可以换成float:left,都可以使其脱离文档流*/ height: 100px; width:

css布局之一列布局

在我们浏览网页中经常看见一列布局其实一列布局就是 一般的一列布局的都是固定宽度的 body{margin:0;padding:0} .main{width:800px;height:300px;background:#ccc;margin:0 auto} <body> <div class="main"></div> </body> margin: 0 auto 就是给div水平居中对齐 在一般做开发的时候,不会设置高度,这里是为了凸显是

CSS自学笔记(15):CSS3多列布局

在CSS3中,也新增了一些关于文本布局的几个比较简单的属性.通过这些新增的属性,我们可以对文本进行简单的排版,就想报纸和杂志那样. 新增的部分属性,以及浏览器支持情况: 属性 浏览器支持 column-count IE Firefox(-moz-) Chrome(-webkit-) Safari(-webkit-) Opera column-gap IE Firefox(-moz-) Chrome(-webkit-) Safari(-webkit-) Opera column-rule IE F