Skip to content Skip to sidebar Skip to footer

Css Class Not Having An Effect On A Div

The following is an section of my CSS file plus some HTML. Can anyone tell me when I put class='containerHeader selected' (as is on Test Header A) the background color is not being

Solution 1:

Use selector div#builderContainer .containerHeader.selected without the space.

Solution 2:

div#builderContainer .containerHeader .selected probably specifies the .selected as a child of containerHeader. Have you tried defining it as #builderContainer .selected instead?

Solution 3:

You need to comma separate your CSS rules.

I think you're expecting div#builderContainer .containerHeader .selected to apply to div#builderContainer, .containerHeader, and .selected, but what it's really applying to is a .selectedinside a .containerHeaderinside a div#builderContainer. Instead, comma separated them:

div#builderContainer, .containerHeader, .selected {
     background-color: Red;
}

Or, if you meant for it to apply to only an element with both classes containerHeader and selected, inside the 'builderContainer', remove the space between those two.

Post a Comment for "Css Class Not Having An Effect On A Div"