Good day. Who knows how to change the properties of an element when hover to the next. Here is a sample code:
/*вот стили(это scss)*/ .nav__list { list-style: none; width: 100%; text-align: justify; &:after { content: ""; display: inline-block; width: 100%; height: 0; } } .nav__item { display: inline-block; position: relative; } .nav__link { color: rgba(255, 255, 255, 0.5); background: transparent; font-family: "OpenSans-Bold", sans-serif; font-size: 12px; text-transform: uppercase; letter-spacing: 2px; cursor: pointer; text-decoration: none; padding: 5px 7px; transition: all 0.3s; &:hover { color: rgba(255, 255, 255, 1); background: red; } } .nav__drop_list { // background: rgba(0,0,0, 0.7); background: red; position: absolute; top: 100%; text-align: left; width: 165px; z-index: 100; display: none; transition: all 0.3s; &-w1 { width: 185px; } &-w2 { width: 210px; } &+.nav__link { background: red; } } .nav__drop_item { margin-bottom: 2px; } .nav__drop_link { color: rgba(255, 255, 255, 1); font-family: "OpenSans-bold", sans-serif; display: block; font-size: 12px; letter-spacing: 1.5px; padding: 7px 15px 7px 10px; text-decoration: none; text-transform: uppercase; transition: all 0.3s; } .nav__item:hover .nav__drop_list { display: block; } .nav__drop_list:hover+.nav__link { background: red; color: rgba(255, 255, 255, 1); } <ul class="nav__list"> <li class="nav__item"> <a href="#" class="nav__link" id="nav__link">Спорт</a> <ul class="nav__drop_list" id="nav__drop_list"> <li class="nav__drop_item"><a href="#" class="nav__drop_link">Пресс</a></li> <li class="nav__drop_item"><a href="#" class="nav__drop_link">Спина</a></li> <li class="nav__drop_item"><a href="#" class="nav__drop_link">Ягодицы</a></li> <li class="nav__drop_item"><a href="#" class="nav__drop_link">Ноги</a></li> <li class="nav__drop_item"><a href="#" class="nav__drop_link">Руки</a></li> </ul> </li> <li class="nav__item"> <a href="#" class="nav__link">Питание</a> <ul class="nav__drop_list nav__drop_list-w1"> <li class="nav__drop_item"><a href="#" class="nav__drop_link">Рецепты</a></li> <li class="nav__drop_item"><a href="#" class="nav__drop_link">Рацион</a></li> </ul> </li> </ul> When hover on the drop-down menu - .nav__drop_list is .nav__drop_list change the background of .nav__link . I tried it via js or via .nav__drop_list:hover + .nav__link , but without success.
What could be the problem?
+acts on the next element, and in your layout.nav__linkpreceded by.nav__drop_list:hover, therefore CSS did not work. Show the script that you tried to link them with. - Gleb Kemarsky