3

I want to select exact element to apply hover effect. But not inherited.

<div class="parent">
    <div class="child"> <-- not here
        <div class="parent">
            <div class="child"></div> <-- apply hover effect
        </div>
    </div>
</div>

is it possible by only CSS ? If it is not possible by only CSS, you can give me idea angularjs directive. Goal is I want to make a reuseable, scaleable angularjs directive or CSS class.

Thank you.

EDIT More clear structure.

<div class="custom-scroller">
    <div class="custom-scrollbar"> <-- not here
        <dynamic-multi-layer-elements>
            ... <-- lots of dynamic number of elements here
            <div class="custom-scroller"> <-- it might be many times nested
                <div class="custom-scrollbar"></div> <-- apply hover effect
            </div>
            ... <-- lots of elements closed
        </dynamic-multi-layer-elements>
    </div>
</div>
6
  • .custom-scroller .custom-scrollbar .custom-scroller > custom-scrollbar:hover { color:#000; } Commented May 9, 2016 at 5:51
  • I don't know how many times it is gonna be nested. It is nested itself. Commented May 9, 2016 at 5:59
  • But is the custom scrollbar added dynamically as well? Commented May 9, 2016 at 6:14
  • yes, custom scroller is container. Commented May 9, 2016 at 6:16
  • How many .custom-scrollbars exist after adding dynamic content? Only two? Commented May 9, 2016 at 6:29

2 Answers 2

4

You can do it like this:

.parent > .child > .parent > .child:hover
{
    color: red;
}
Sign up to request clarification or add additional context in comments.

Comments

0
.parent .parent > .child:hover
{
color:green;
}

you can do it like that

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.