1. 程式人生 > >css樣式選擇器的型別---lesson2

css樣式選擇器的型別---lesson2

css樣式選擇器有4類:

1、類選擇器,可以作用任何html元素

2、id選擇器,僅用於一個html元素

3、標籤選擇器,用於相同的html標籤元素

4、複合內容選擇器,基於選擇的內容

基本使用範例:

截圖:


程式碼:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
.zs-item {
	font-size: 18px;
	color: #F60;
}
#zs-first {
	font-size: 24px;
	color: #309;
}
a {
	font-size: 14px;
	color: #99F;
}
a:link {
	color: #f00;
}
a:visited {
	color: #0f0;
}
a:hover {
	color: #00f;
}
a:active {
	color: #FCF;
}
h1,h2,h3{
	color:#309;	
}

#item-btn button {
	font-size: 18px;
	font-weight: bold;
	text-transform: none;
	font-family: "Arial Black", Gadget, sans-serif;
	font-style: normal;
	line-height: normal;
	background-color: #0CC;
	width: auto;
	float: left;
	clear: none;
	padding: 20px;
	list-style-type: none;
}
</style>
</head>
<body>
<p class="zs-item">今天天氣不錯!
</p>
<p id="zs-first">天很藍</p>
<em><strong><a href="http://www.baidu.com">去外面看看把 </a>
</strong></em>
<h1>我是h1</h1>
<h2>我是h2</h2>
<h3>我是h3</h3>
<div id="item-btn">
	<button>真無聊</button>
</div>
<button>真無聊2</button>
</body>
</html>


更加詳細的可以參考下面圖片設定規則: