多类选择器和后代选择器的区别

2019-11-21  本文已影响0人  黑哥聊dotNet

<html>

<head>

<style type="text/css">

.important {font-weight:bold;}

.warning {font-style:italic;}

.important.warning {background:silver;}

</style>

</head>

<body>

<p class="important">This paragraph is very important.</p>

<div class="important">

<p class="warning">This is a warning.</p>

</div>

<p class="important urgent warning">This paragraph is a very important warning.</p>

<p>This is a paragraph.</p>

<p>...</p>

</body>

</html>

多类选择器代码

注意.important.warning 是挨着一起的

结果

后代选择器

后代选择器

注意.important .warning 是分开的

结果

注意两者分别

上一篇 下一篇

猜你喜欢

热点阅读