CUTCODEDOWN
Minimalist Semantic Markup

Welcome Guest
Please Login or Register

If you have registered but not recieved your activation e-mail in a reasonable amount of time, or have issues with using the registration form, please use our Contact Form for assistance. Include both your username and the e-mail you tried to register with.

Author Topic: Mixing nth of type with before  (Read 111 times)

AndrewTraub

  • Jr. Member
  • **
  • Posts: 76
  • Karma: +0/-0
Mixing nth of type with before
« on: 1 Jan 2023, 05:06:26 pm »
I'm adding an element in front of an H2 tag using the before pseudocode. I want a different color for the 2nd, 3rd, and 4th, so I've tried this code to no avail:

.containerClass h2:before { //this part works and the content is output
  /* container content goes here, this is just an example */
  background-color: blue;
}

.containerClass h2:nth-of-type(2):before {
    background-color: var(--warning); //should change the color of what is output but does not
}

I've also tried ...h2:before:nth-of-type(2) and neither changes the background color.  Am I using the wrong selector or do :nth-of-type and :before not combine

if it matters, the actual structure is:
div.containerClass
 section
   h2

coothead

  • Sr. Member
  • ****
  • Posts: 355
  • Karma: +88/-0
  • I smile benignly
    • coothead's stuff ~ an eclectic collection
Re: Mixing nth of type with before
« Reply #1 on: 1 Jan 2023, 05:37:19 pm »
Hi there AndrewTraub,

will you please post your actual HTML and  CSS that you are using.

coothead
~ the original bald headed old fart ~

 

SMF spam blocked by CleanTalk

Advertisement