I have a wordpress site where the divs are ID’s and cant just make the one background color black. I have tried :nth-child(1) and :nt-child(3) but its not working. And I cant change the ID’s as its part of the theme.
Just want to make the 1st one and last one have a background color of black. Even tried
#page-services:nth-child(odd) {
background-color: #000;
}
<div id="page-services">
<div class="divider-xl"> text </div>
</div>
<div id="page-services">
<div class="divider-xl"> text </div>
</div>
<div id="page-services">
<div class="divider-xl"> text </div>
</div>
2
Answers
Cause more ID selectors with same name are not semantic.
Use:
#your_container div:nth-child…
Or try to edit ID’s in jQuery.
ID’s must be only used once per page. Change the ID to a class.