css关系选择符

本文深入探讨了CSS样式的基本应用及选择器的使用方法,包括边框圆角、相邻兄弟选择器、子元素选择器、伪类选择器等,并通过实例展示了如何灵活运用这些特性来美化网页布局。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<!Doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>testcss3</title>

<script type="text/javascript" >

</script>
<style>
	div{
		text-align: center;
		border: 2px solid #a1a1a1;
		padding: 10px 40px;
		background: #dddddd;
		width: 350px;
		border-radius: 25px;
		box-shadow: 10px 10px 5px #dddddd;
	}
/*	相邻兄弟选择器 h1和p相邻 的p*/
	.div2 h1 + p{background-color: aqua;}
/*	子元素选择器*/
	h1 > strong {color: red;}
/*	伪类*/
	a:link {color: #FF0000}		/* 未访问的链接 up*/
	a:visited {color: #00FF00}	/* 已访问的链接 */
	a:hover {color: #FF00FF}	/* 鼠标移动到链接上 over*/
	a:active {color: #0000FF}	/* 选定的链接 down */
	
	.div3 p:first-child{font-weight: bold;}
	.div3 li:first-child{text-transform:uppercase;}
	.div4 p:first-child i{color: blue;}
	
	.div2 h1:before{content: "hello";}
</style>
</head>
<body>
	<div>border-radius 属性允许您向元素添加圆角</div>
	
	<div class="div2">
		<h1>This is a heading.</h1>
		<p>This is paragraph.</p>
		<p>This is paragraph.</p>
		<p>This is paragraph.</p>
		<p>This is paragraph.</p>
		<p>This is paragraph.</p>
	</div>
	
	<h1>This is <strong>very</strong> <strong>very</strong> important.</h1>
	<h1>This is <em>really <strong>very</strong></em> important.</h1>
	
	<div class="div3">
		<p>These are the necessary steps:</p>
		<ul>
		<li>Intert Key</li>
		<li>Turn key <strong>clockwise</strong></li>
		<li>Push accelerator</li>
		</ul>
		<p>Do <em>not</em> push the brake at the same time as the accelerator.</p>
	</div>
	<div class="div4">
		<p>some <i>text</i>. some <i>text</i>.</p>
		<p>some <i>text</i>. some <i>text</i>.</p>
	</div>
</body>
</html>

http://www.w3school.com.cn/css/css_selector_child.asp

.reveal *{display: none;}
/*reveal 的子元素都不显示 没有*的话就是本身加子元素都不显示*/
.reveal *.handle{display: block;}
/*除了class="handle"的元素*/

css 关系选择符:

1:包含选择符 E F(sRules)

2:子选择符 E>F(sRules)

3.相邻选择符(E+F)

4.兄弟选择符(E~F)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值