nth-of-type CSS selector hierarchy issues -


I want the background color of a div in the alternative. The red, black, red, black ... elements are at the same level, but I am unable to work in this case:

  
div class = "after Preview-cover "& gt; & Lt; Div class = "post-preview" & gt; & Lt; H1 & gt; Advertising for website & Lt; / H1> & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Div class = "post-preview-wrapper" & gt; & Lt; Div class = "post-preview" & gt; & Lt; H1 & gt; Adipisicing Elite A Communications Company Limited. & Lt; / H1> & Lt; / Div & gt; & Lt; / Div & gt;

and css

 . Post-preview: nth-of-type (even) {background-color: red; } .post-preview: nth-of-type (weird) {background-color: black; }  

How to set the selector properly? Thanks a lot!

You can turn on nth-child container ... < / P>

  .post-preview-wrapper: nth-of-type (even) .post-preview {background-color: red; } .post-preview-wrapper: nth-of-type (weird) .post-preview {background color: black; White color; }  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -