All I want DIVs from red to pink to be colored red and DIVs from pink to red to be colored pink. But this does not work (all is red):
<!DOCTYPE HTML>
<html>
<head>
<style>
div {
display: inline-block;
padding: 50px;
background: yellow;
border: solid 1px black;
}
.pink div {
background: pink;
}
.red div {
background: red;
}
</style>
</head>
<body>
<div class="red">
<div>
<div>
<div>
<div>
<div class="pink">
<div>
<div>
<div class="red">
<div>
<div>
<div>
<div class="pink">
<div>
<div>
<div>
<div>
<!-- and so on -->
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
I know why it doesn't work but now I am looking for a solution. Please suggest anything as long as:
- it is in pure CSS;
- it doesn't require defining IDs;
- it can work for any numbers of DIVs;
- the class names (
redandpink) can be defined for any of the DIVs.