I have to style an image with the class offer-img
<section class="offer">
<div class="container">
<div class="row">
<div class="col-2">
<!-- The image I want to style -->
<img src="img.png" class="offer-img">
</div>
<div class=".."> ... </div>
</div>
</div>
</section>
In my style.css, when I try to access it with
/* somewhere above the hierarchy */
.col-2 img{
max-width: 100%;
padding: 50px 0;
background-size: cover;
}
/* Not working
.offer-img {
padding: 40px;
}
*/
/* Works fine */
.col-2 .offer-img {
padding: 40px;
}
Edited:
- When I try to access the
.offer-imgdirectly, my style is not applied. - It only works when I change
.offer-imgto.col-2 .offer-img - Why
.col-2 img's padding is overriding.offer-img's padding? - Is
.col-2 imgmore specific than.offer-img