0

I have 4 levels of divs. I need to add css properties to the "ml-accordion-pane" class only if the "myhiddenagenda" class is present.

<div class="mk-accordion-pane" style="display: block;">         
    <div class="wpb_raw_code wpb_content_element wpb_raw_html">
        <div class="wpb_wrapper">
            <div class="myhiddenagenda">
            </div>
        </div> 
    </div> 
</div>

I tried the following but it didn't work

.mk-accordion-pane > .wpb_raw_code > .wpb_wrapper > .myhiddenagenda {
color:#555;
background-color:#000;
}

anyone got any ideas?

  • 2
    With CSS...you can't. Jquery is your friend – Paulie_D Apr 17 '14 at 15:15
  • You can't add a parent in CSS. – Albzi Apr 17 '14 at 15:16
  • This requires JavaScript. Not necessarily jQuery. – TylerH Apr 17 '14 at 15:19
  • What you are looking for is a parent selector. There is no parent selector in CSS as yet. So, you won't be able to do this in CSS. However, to achieve what you want, you can make use of Javascript/ JQuery. As others have pointed, this question should be marked as duplicate. – Satwik Nadkarny Apr 17 '14 at 15:22
  • Thanks for the quick responses. I'm open to a Jquery Solution as well. I was able to find a query solution for a parent selection, but not for a "parent of a parent etc". – user3545805 Apr 17 '14 at 15:24

1 Answers1

-1

I think it is imposible to do it with Css only. You should use jQuery to do it.

Kwader
  • 143
  • 7