A
A
Alex-HAV2018-02-05 18:43:14
css
Alex-HAV, 2018-02-05 18:43:14

Is it possible with CSS to check for the presence of a child element and change the background?

Good day!
There is such a task, I want to know if it is possible to implement it using CSS.
There is a drop-down menu that drops out when hovering over a div (area with a link). In this menu, in the normal state, there are 5 items, but under certain conditions, the 6th item appears with its own class.
I would like to color the area that I need to hover over for the drop-down menu to be red if this 6th item is there.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kirito Kagurazaka, 2018-02-05
@shomin2112

css doesn't have that option.
Try it, I don’t know whether it will work on your layout or not, but the solution is quite real.

.menu {
background-color:transparent;//обязательно
}

.menu>.submenu>.red::before {
background-color:red
position:absolute;
z-index:-1;
x:позиция .menu;
y:позиция .menu;
width:ширина .menu;
height:высота .menu;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question