css - 这个紧邻同胞选择符的问题
本文介绍了css - 这个紧邻同胞选择符的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>font-test</title>
<style>
h1+p {color: black; font-style: italic;}
p {color: gray; background: white; font-style: normal;}
.aside {color: black; background: silver;}
</style>
</head>
<body>
<h1>Greetings!</h1>
<p class="aside">It's a fine way to start a day.</p>
<p>There are many ways to greet a person.</p>
<h1>Salutations!</h1>
<p>Although a thick and juicy hamburger with bacon and mushrooms runs a close second.</p>
<p class="aside">There is nothing finer than a heaety welcome frome one's fellow man.</p>
</body>
</html>
显示效果如下:
我想问一下,第二个段落和第四个段落的字体为什么不是斜体?h1+p选择符没有选择这两段吗?
解决方案
h1+p 选择器是指 h1 下面的p。
这篇关于css - 这个紧邻同胞选择符的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文