Answer the question
In order to leave comments, you need to log in
How do you describe an element's active class in Sass?
I will give a simple example to make it easier to understand.
<div class="menu">
<div class="menu__item">
<a class="menu__link" href="/">Главная</a>
<span class="menu__img"></span>
</div>
<div class="menu__item menu__item_active">
<a class="menu__link" href="/services/">Услуги</a>
<span class="menu__description">
Список доступных услуг.
<span class="menu__img"></span>
</span>
</div>
</div>
.menu {
position: relative;
&__item {
display: block;
margin-bottom: 5px;
position: relative;
}
&__link {
display: block;
font-size: 1rem;
color: blue;
&:hover {
color: red;
}
}
&__img {
position: absolute;
width: 10px;
height: 10px;
display: none;
}
}
Answer the question
In order to leave comments, you need to log in
.menu {
position: relative;
&__item {
display: block;
margin-bottom: 5px;
position: relative;
}
&__link {
display: block;
font-size: 1rem;
color: blue;
}
&__img {
position: absolute;
width: 10px;
height: 10px;
display: none;
}
//==
//== Hover & active states
//== ======================================= ==//
&__link:hover,
&__link_active {
color: red;
}
&__link:hover + &__img,
&__link_active + &__img {
display block;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question