Navbar Bootstrap opening wrong link on points of the site

Asked

Viewed 167 times

0

On my site I have a menu that I add with header.php in certain parts of the site, home and its symbolic links. the problem is when you go from the horizontal menu to that button that opens responsive. if I’m on one on the internal links and click on the button it will open the menu of the home and not the internal link( simbolico) I’m in question.

Index.php

   esse é o principal que ele sempre abre.
   <div class="wrapper">
    <?php
        include("header.php");
    ?>....
   <div id="qualidade-page" class="wrapper">
    <?php
    include("header.php");
    ?>...
 <div id="contato-page" class="wrapper">
    <?php
    include("header.php");
    ?>....

header.php

 <div class="main-header">
   <a href="index.php" class="logo">
     <!-- mini logo for sidebar mini 50x50 pixels -->
     <span class="title">titulo </span>
</a>
    <p class="title-lateral>subtitulo</p>
   <div class="menu">
       <nav class="navbar navbar-expand-lg navbar-light bg-light">
       <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo01" aria-controls="navbarTogglerDemo01" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarTogglerDemo01">
<ul class="navbar-nav mr-auto my-2 my-lg-0">
  <li class="nav-item">
    <a class="nav-link" href="index.php#produtos-page" >Produtos</a>
  </li>
  <li class="nav-item">
    <a class="nav-link "  href="index.php#qualidade-page">Qualidade</a>
  </li>
   <li class="nav-item">
    <a class="nav-link" href="index.php#contato-page" >Contato</a>
  </li>
</ul>
</div>
</nav>
</div>
</div>

css

.menu{
    margin-top: 1%;
    width: 100%;
    background-color: #E8E8E8;
    height: 60%;
}

.nav-item{
    padding-right: 3%;
    padding-top: 1%;
    padding-left: 1%;

}
.nav-item a{
    color:#5b5454;
}
  • It was a little confusing to understand... Apparently you have only one navbar, but you call the same Navbar in three different places... because you do this? You get 3Navs equal at the same time on the same page that’s right?

  • That would be it. In fact, I realized that it wouldn’t be very smart. would know how I do to have only one navbar and it accompany the scroll or the symbological links, in case stay always at the top of the symbological link.

  • 1

    First do only 1 include from this Menu, then in the documentation you have your answer https://getbootstrap.com/docs/4.0/components/navbar/#placement . Anchors shall be of the type href="#produtos-page" since the corresponding ID is on the same page, so you don’t need home.php before. This answer in a Bootstrap Menu that is fixed at the top, in your case just remove the blue div and it will already stay at the top https://answall.com/questions/387949/barra-navega%C3%A7%C3%A3o-no-bootstrap/387960#387960

  • is that I was using the same Nav on another specific page, so for it to redirect need index from the front. This would be bad practice ?

  • 1

    In that case it’s not bad practice.

No answers

Browser other questions tagged

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