I
I
inzoddex2019-07-13 15:06:21
css
inzoddex, 2019-07-13 15:06:21

How to show one element when hovering over another in SASS?

There is such a structure

<div class="dropdown">
    <button class="dropdown__button">
        <i class="fas fa-bars"></i>
        <span>Категории</span>
    </button>
     <div class="dropdown__content">
           <a href="#" class="dropdown__link">Межкомнатные двери</a>
            <a href="#" class="dropdown__link">Входные двери</a>
            <a href="#" class="dropdown__link">Фурнитура</a>
            <a href="#" class="dropdown__link">Лестницы</a>
            <a href="#" class="dropdown__link">Мебель</a>
            <a href="#" class="dropdown__link">Арки</a>
            <a href="#" class="dropdown__link">Услуги</a>
      </div>
 </div>

And its styling in SASS
.dropdown 
    width: 235px
    &__button
        width: 100%
        text-align-last: left
        padding: 14px 0px 14px 27px
        box-sizing: border-box
        cursor: pointer
        font-size: 18px
        text-transform: uppercase
        color: #ffffff
        background-color: $color-primary
        border: none
        span
            padding-left: 5px

    &__content
        display: none
                
    &__link
        padding: 20px 0px 20px 27px
        border-bottom: 1px solid rgba(209, 209, 209, .5)
        color: $color-adding

How to make it so that when hovering over the CATEGORY button, nested elements are displayed?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2019-07-13
@inzoddex

.dropdown
    &__button:hover + &__content,
    &__content:hover
        display: block

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question