3.CSS

简介

  • CSS 指层叠样式表 (Cascading Style Sheets)
  • 外部样式表可以极大提高工作效率
  • 样式定义如何显示 HTML 元素
  • 外部样式表通常存储在 CSS 文件中
  • 多个样式定义可层叠为一
  • 把样式添加到 HTML 4.0 中,是为了解决内容与表现分离的问题




选择器

<html>
<head>
	<title>This is the title</title>
	<style>
		h1{         #元素选择器
			color:red;#定义前景色
			background-color:yellow;
		}
		#content{   #id选择器
			color:black:
			background-color:white;
		}
		.content{   #类选择器
			color:blue;
			background-color:green;
			font-size:16px;
		}
		a[href]{    #属性选择器
			color:darkbule;
			font-size:23px;
		}
		h2 em{      #后代选择器
			color:oldlace;
		}
		h3 >l{      #子元素选择器
			color:orange;
			border:green solid 1px; #dashed为实心边框
		}
		li + p{     #相邻兄弟选择器
			font-weight:bold;
			outline:greenyellow dotted 5px;#轮廓
		}
	</style>
</head>
<body>
	<h1>This is the content</h1>
	<h2 id="content">This is the another content</h1>
	<h2 class="content">This is the another content</h1>
	<a href>This is the another content</a>
	<h2><em>still a content</em></h2>
	<h3>Again <em>is </em>a <l>the </l>content</h3>
	<ul>
		<li>Last a the content</li>
		<p>Last a the content</p>
		<li>Lat a the content</li>
		<p>Last a the content</p>
	</ul>
	<p>Last a the content</p>
</body>
</html>

在这里插入图片描述





伪类

发布了3 篇原创文章 · 获赞 2 · 访问量 199

猜你喜欢

转载自blog.csdn.net/weixin_45131319/article/details/104380296