1
I’m using the Sticky-top bootstrap class to pin the menu to the top. But I wish that as long as the menu was not fixed, the icon would not appear.
I mean .menu-principal img
, I would like when the menu is fixed at the top the opacity of .menu-principal img
changes from 0 to 1. I’m using jquery, bootstrap and the visibility plugin. I’m a beginner in web development.
This is the menu:
<nav class=" sticky-top menu-principal navbar navbar-expand-lg navbar-dark">
<div class="container d-flex justify-content-between">
<span style="display: block; width: 56px;"></span>
<a class="navbar-brand m-0" href="index.html">
<img src="icons/logo-simples.svg" alt="logotipo simplificado">
</a>
<button class="navbar-toggler float-right" data-toggle="collapse"
data-target="#navbarMenu">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse justify-content-end" id="navbarMenu">
<div class="navbar-nav">
<a href="index.html" class="nav-item nav-link active"> Home</a>
<a href="portfolio.html" class="nav-item nav-link"> Portfolio</a>
<a href="historia.html" class="nav-item nav-link"> História</a>
<a href="sobre.html" class="nav-item nav-link"> Sobre</a>
</div>
</div>
</div>
</nav>
This is the CSS of the Menu
.menu-principal {
background-color: #1C4F6E;
font-weight: bold;
letter-spacing: 2px;
}
.menu-principal .navbar-nav a {
color: #FFF !important;
margin-left: 6px;
margin-right: 6px;
}
.menu-principal .navbar-nav .active {
color: #FF9127 !important;
}
.menu-principal .navbar-nav a:hover {
color: #FF9127 !important;
}
.menu-principal img {
opacity: 0;
height: 60px;
}
@media screen and (max-width: 991px) {
.menu-principal img {
height: 50px;
}
.menu-principal .navbar-nav a {
margin: 0;
padding: 10px;
}
.navbar-nav {
padding: 10px;
}
.navbar-toggler {
margin-top: 10px;
}
.menu-principal .container {
display: inline-block;
text-align: center;
}
}
Thanks, that’s exactly what I’ve been wanting
– user124107
@Erulos tranqilo young, I’m glad you helped there, if you don’t want to use the
fadeIn / Out
vc can add or remove a class, ai vc creates the class you want to remove/add and in the Script you exchange where it isfadeIn
foraddClass
andremoveClass
– hugocsl