How to change default background-color of . active Bootstrap 4

Asked

Viewed 446 times

-2

Good colleagues. I have a small problem that I have not been able to solve, the question is this: I intend to change the color of an element that is dropdown-item when it is active, that is when it is in the current page. I’ll leave some images and html code to help you understand.I went through some posts, but it didn’t work....

Imagem do elemento no website

source code

<header>
....
<nav>
....
<div class="dropdown">
                                    <a
                                        href="/_pages/gallery.html" class="nav-link
                                        font-weight-bolder dropdown-toggle nav-item
                                        mr-3" role="button" id="dropdownmenu"
                                        data-toggle="dropdown" aria-haspopup="true"
                                        aria-expanded="false">Galeria</a>
                                    <div class="dropdown-menu mt-2"
                                        aria-labelledby="dropdownmenu">
                                        <a href="/_pages/gallery-pictures.html" class="dropdown-item">Fotografias</a>
                                        <a href="/_pages/gallery-videos.html" class="dropdown-item">Videos</a>
                                    </div>
                                </div>
</nav>
</header>

1 answer

0

You need to change the style of the class dropdown. Nestled to it, the active button class is .dropdown-item .active

The css looks like this:

.dropdown-item.active,
.dropdown-item:active {
  background: #000;
  color: #fff
}

See more in the bootstrap documentation: https://getbootstrap.com/docs/4.2/components/dropdowns/

  • Unfortunately it didn’t work had already done something similar, but it had not worked

Browser other questions tagged

You are not signed in. Login or sign up in order to post.