CSS层叠样式表

CSS(cascading style sheets)

层叠样式表

选择器
  • 类选择器(.加上类名字)

    <!DOCTYPE html>
    <html>
    	<head>
    		<meta charset="UTF-8">
    		<title></title>
    		<style type="text/css">
    			.container{
    				width: 960px;
    				min-height: 1000px;
    				background: pink;
    				float: left;
    			}
    			.head{
    				width: 100%;
    				height: 200px;
    				background: skyblue;
    				float: left;
    			}
    			
    			.body{
    				width: 100%;
    				/*height: 700px;*/
    				float: left;
    				background: greenyellow;
    				
    			}
    			/*
    			 设置
    			 * */
    			.body .main{
    				width: 70%;
    				height: 700px;
    				background: red;
    				float: left;
    			}
    			
    			.body .sub{
    				width: 29%;
    				height: 700px;
    				background: cornsilk;
    				float: right;
    			}
    			
    			.foot{
    				float: left;
    				width: 100%;
    				height: 100px;
    				background: darkgray;
    			}
    		</style>
    	</head>
    	<body>
    		<div id="" class="container">
    			<!--头开始了-->
    			<div class="head">
    				
    			</div>
    			<!--头结束了-->
    			<!--体开始了-->
    			<div class="body">
    				<div class="main"></div>
    				<div class="sub"></div>
    			</div>
    			<!--体结束了-->
    			<!--尾开始了-->
    			<div class="foot"></div>
    			<!--尾结束了-->
    		</div>
    	</body>
    </html>
    
    
  • 标签选择器

div{

}
  • id选择器(#加上id名字)

搭建网站布局

<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<style type="text/css">
			.container {
				background: chocolate;
				width: 700px;
				height: 700px;
			}
			
			.head {
				background: skyblue;
				width: 100%;
				height: 100px;
			}
			.all{
				background: red;
				width: 100%;
				height: 500px;
			}
			.menu{
				background: #000000;
				width: 30%;
				height: 100%;
				float: left;
			}
			.main{
				background: #FFFF00;
				width: 70%;
				height: 100%;
				float:right;
			}
			.footer{
				background: gray;
				width: 700px;
				height: 100px;
			}
		</style>
	</head>

	<body>
		<div class="container">
			<!--头开始了-->
			<div class="head">

			</div>
			<!--头结束了-->
			<div class="all">
				<!--菜单开始了-->
				<div class="menu">

				</div>
				<!--菜单结束了-->
				<!--主页面开始了-->
				<div class="main">

				</div>
				<!--主页面结束了-->
			</div>

			<!--尾开始了-->
			<div class="footer">

			</div>
			<!--尾结束了-->
		</div>
	</body>

</html>

两个子div标签,一个设置为左浮动,一个设置为右浮动。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值