CSS 分组和嵌套

组选择器

<!DOCTYPE html >
<html>
	<head>
		<meta charset="utf-8"> 
		<title>自学教程(如约智惠.com)</title> 
		<style>
			h1,h2,p {color:green;}
		</style>
	</head>
	<body>
		<h1>Hello World!</h1>
		<h2>Smaller heading!</h2>
		<p>This is a paragraph.</p>
	</body>
</html>

嵌套选择器

<!DOCTYPE html >
<html>
	<head>
		<meta charset="utf-8"> 
		<title>自学教程(如约智惠.com)</title> 
		<style>
			p {
				color:blue;
				text-align:center;
			}
			
			.marked {
				background-color:red;
			}
			
			.marked p{
				color:white;
			}
			
			p.marked {
				text-decoration:underline;
			}
		</style>
	</head>
	<body>
		<p>这个段落是蓝色文本,居中对齐。</p>
		<div class="marked">
			<p>这个段落不是蓝色文本。</p>
		</div>
		
		<p>所有 class="marked"元素内的 p 元素指定一个样式,但有不同的文本颜色。</p>	
		<p class="marked">带下划线的 p 段落。</p>
	</body>
</html>

参考:https://www.yuque.com/docs/share/540890ba-54a9-49a0-a922-53266f0a2943

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值