Apply CSS styles to all elements except nested elements
P粉865900994
P粉865900994 2023-08-01 14:15:45
0
1
456
<p>As an example, if I want Text1 to be red, but not Text2:</p> <pre class="brush:php;toolbar:false;"><div class="red"> Text1 <p class="notred">Text2</p> </div></pre> <p>I tried this in css:</p> <pre class="brush:php;toolbar:false;">.red :not(.notred) { color: #ff0000; }</pre> <p>Try this, it does not apply styles Text1 or Text2. </p>
P粉865900994
P粉865900994

reply all(1)
P粉574695215


<!DOCTYPE html>
<html>
<style>
.red {
  color: #ff0000;
}
.notred{
  color: #000000;
}
</style>
<body>

<div class="red">
Text1
<p class="notred">Text2</p>
</div>

</body>
</html>


You can do this.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!