I'm trying to do a background
with last-child
and I do not understand very well why it does not apply the style I want. I want the last div
containing the child class to have background
, how can I do it? SOMETHING IS BAD.
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
.hijo {
display: block;
width: 100px;
height: 100px;
border:1px solid red;
}
.hijo:last-child {
background: #ff0000;
}
.hermano {
display: block;
width: 100px;
height: 100px;
border: 1px solid green;
}
</style>
</head>
<body>
<div style="width: 100%; height: 100vh; border: 1px solid #000;">
<div class="hijo">
<p>ESTO ES UN TEST</p>
</div>
<div class="hijo">
<p>ESTO ES UN TEST</p>
</div>
<div class="hijo">
<p>ESTO ES UN TEST</p>
</div>
<div class="hijo">
<p>ESTO ES UN TEST</p>
</div>
<div class="hijo">
<p>ESTO ES UN TEST</p>
</div>
<div class="hermano"></div>
</div>
</body>
</html>