Blogger Information
Blog 4
fans 0
comment 0
visits 2448
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
常用css选择器和优先级练习----2019年1月14日23时30分
aptx_1999的博客
Original
730 people have browsed it

熟练使用css进行网页美化,能给页面带来丰富的内容和色彩

实例

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>常用选择器与优先级(seceltor)</title>
	<style>
		/*标签选择器*/
		h3 {
			background-color:lightgreen;
			color:red;
		}
		/*class选择器*/
		.bg-blue{
			background-color: skyblue;
		}
		/*id选择器*/
		#bg-yellow{
			background-color: yellow;
		}

	</style>
</head>
<body>
	<h3 class="bg-blue">样式规则 = 选择器 + 样式声明</h3>
	<h3 class="bg-blue" id="bg-yellow" style="background-color:pink">样式规则 = 选择器 + 样式声明</h3>
	<!--选择器优先级顺序 标签 < class < id-->
	<!--用js实现更改h3标签背景色-->
	<script type="text/javascript">
	document.getElementById('bg-yellow').style.backgroundColor = 'lightgrey';

	</script>
</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例

以上代码涉及知识点总结:

一.常用css选择器有标签选择器、类class选择器、id选择器,类选择器用 . 引用,id选择器用 # 引用

二.优先级顺序是 标签 < class < id

三.比id选择器更高级的可以用js,如document.getElementById('id选择器名字').style.backgroundColor='颜色',更改id属性的元素的背景色。

Correction status:Uncorrected

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post