html+css初级篇

3 篇文章 0 订阅
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>css</title>
	<!-- 链接外部css -->
	<link rel="stylesheet" type="text/css" href="lesson3_1.css">
	<!-- 和下面的style效果相同 -->
<!-- 	<style type="text/css">
		div{
			width: 100px;
			height: 100px;
			background-color: green;
		}
	</style> -->
</head>
<body>
<!-- 	
IE 						trident
Firfox					Gecko
Google chrome			Webkit/blink
Safari					Webkit
Opera					presto
 -->
 	<!-- cascading style sheet 层叠样式表 -->

 		<!-- 1.引入css -->
 		<!-- (1)行间样式 -->
 		<div style=""></div>
 		<!-- (2)页面级标签<head><style> -->
 		<!-- (3)外部css -->

 		<!-- 选择器 -->
 		<!-- 1.id选择器 :一一对应-->
 		<div id="only">123</div>
 		<div id="only1">456</div>
 		<!-- 2.class :一对多-->
 		<div class="demo demo1">789</div>
 		<div class="demo">dfa</div>
 		<!-- 3.标签选择器 -->
 		<span>123</span>
 		<div>
 			<span>234</span>
 		</div>
 		<!-- 4.通配符 -->
 		<span>123</span>
 		<div>567</div>

 		<!-- 选择器优先级:!important> id>class|属性选择器>标签选择器>通配符选择器-->
 		<div id="only1" class="demo">dfaklg</div>
 		<div style="background-color: red;" id="only1">faflaf</div>


 		
</body>
</html>

/*css权重*/
/*!important 				infinity
行间样式				1000
id选择器 				100
class|属性|伪类			10
标签|伪元素				1
通配符    				0

*/


/*标签选择器*/
div{
	/*width: 100px;*/
	/*height: 100px;*/
	background-color: red;
	/*border-radius: 50%;*/
}
/*id选择器*/
#only{
	background-color: red;
}
#only1{
	background-color: green;
}
/*class选择器*/
/*important提高优先级*/
.demo{
	background-color: blue!important;
}
.demo1{
	color: #fcc;
}
span{
	color: #F40;
	font-weight: bold;
}
/*通配符选择器*/
*{
	background-color: yellow;
}
/*属性选择器*/
[id="only"]{
	font-weight: bold;
	background-color: #fcc;
}
[class]{
	font-weight: bold;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值