Image on top of links

Asked

Viewed 39 times

2

Good afternoon, you guys. I made a navbar and in the center put an image, only that in that image is on top of the links in the navbar, already tried some things like z-index but no objective result. If anyone can help me, I’d really appreciate it. follows the code

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
}
body {
    font-family: "Helvetica Neue",sans-serif;
    font-weight: lighter;
}
header {
    width: 100%;
}
nav {
    position: fixed;
    width: 100%;
    z-index: 5;
    background: #471e12;
}
nav ul {
    line-height: 68px;
    list-style: none;
    background: rgba(71, 30, 18, 0);
    overflow: hidden;
    color: #fff;
    text-align: center;
    margin: 0;
    padding: 0 40px 0 0;
    transition: 1s;
}
nav.black ul {
    background: #471e12;
}
nav ul li {
    display: inline-block;
    padding: 16px 40px;;
}
nav ul li a {
    text-decoration: none;
    color: #fff;
    font-size: 16px;
}
nav ul li a:hover {
    text-decoration: none;
    color: #fff;
    font-size: 16px;
}
.menu-icon {
    line-height: 60px;
    width: 100%;
    background: #471e12;
    text-align: right;
    box-sizing: border-box;
    padding: 15px 24px;
    cursor: pointer;
    color: #fff;
    display: none;
}
#logo-menu{
    position: fixed;
    margin-left: 0;
    margin-right: 0;
    width: 100%;
    height: 30%;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    float: top;
    z-index: 1;
}
#logo-menu img{
    width: 15%;

}
#menu1{
    float: left;
    z-index: 6;
}
#menu2{
    float: right;
    z-index: 6;
}
@media(max-width: 786px) {
    .logo {
        position: fixed;
        top: 0;
        margin-top: 16px;
    }
    nav ul {
        max-height: 0;
        background: #471e12;
    }
    nav.black ul {
        background: #471e12;
    }
    .showing {
        max-height: 34em;
    }
    nav ul li {
        box-sizing: border-box;
        width: 100%;
        padding: 24px;
        text-align: center;
    }
    .menu-icon {
        display: block;
    }
}
<!DOCTYPE html>
<html lang="pt-br">
   <!-- INSPIRAÇÕES :
      http://preview.milingona.co/themes/bakery/main/
      http://whatpixel.com/bakery-web-design-inspiration/
      -->
   <head>
      <!-- ====================   FAV ICONS ==================== -->
      <link rel="apple-touch-icon" sizes="57x57" href="img/fav-icon/apple-icon-57x57.png">
      <link rel="apple-touch-icon" sizes="60x60" href="img/fav-icon/apple-icon-60x60.png">
      <link rel="apple-touch-icon" sizes="72x72" href="img/fav-icon/apple-icon-72x72.png">
      <link rel="apple-touch-icon" sizes="76x76" href="img/fav-icon/apple-icon-76x76.png">
      <link rel="apple-touch-icon" sizes="114x114" href="img/fav-icon/apple-icon-114x114.png">
      <link rel="apple-touch-icon" sizes="120x120" href="img/fav-icon/apple-icon-120x120.png">
      <link rel="apple-touch-icon" sizes="144x144" href="img/fav-icon/apple-icon-144x144.png">
      <link rel="apple-touch-icon" sizes="152x152" href="img/fav-icon/apple-icon-152x152.png">
      <link rel="apple-touch-icon" sizes="180x180" href="img/fav-icon/apple-icon-180x180.png">
      <link rel="icon" type="image/png" sizes="192x192"  href="img/fav-icon/android-icon-192x192.png">
      <link rel="icon" type="image/png" sizes="32x32" href="img/fav-icon/favicon-32x32.png">
      <link rel="icon" type="image/png" sizes="96x96" href="img/fav-icon/favicon-96x96.png">
      <link rel="icon" type="image/png" sizes="16x16" href="img/fav-icon/favicon-16x16.png">
      <link rel="manifest" href="img/fav-icon/manifest.json">
      <meta name="msapplication-TileColor" content="#ffffff">
      <meta name="msapplication-TileImage" content="img/fav-icon/ms-icon-144x144.png">
      <meta name="theme-color" content="#ffffff">
      <!-- ======================== JQUERY ======================== -->
      <script type="javascript" src="node_modules/jquery/dist/jquery.js"></script>
      <script type="javascript" src="node_modules/popper.js/dist/popper.js"></script>
      <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ" crossorigin="anonymous"></script>
      <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" crossorigin="anonymous"></script>
      <!-- ======================== CSS ======================== -->
      <link rel="stylesheet" href="css/style.css">
      <!-- ======================== BOOTSTRAP ======================== -->
      <link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.css">
      <link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap-grid.css">
      <link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap-reboot.css">
      <link rel="stylesheet" href="node_modules/font-awesome/css/font-awesome.css">
      <link rel="stylesheet" href="node_modules/font-awesome/scss/font-awesome.scss">
      <!-- ============++========  FONTES ==================== -->
      <link href="https://fonts.googleapis.com/css?family=Quicksand" rel="stylesheet">
      <!-- ====================  METAS ==================== -->
      <meta name="description" content="Confeitaria feita com uma boa pitade de amor.">
      <meta name="keywords" content="confeitaria, bolos, doces,">
      <meta name="robots" content="index, follow">
      <meta name="revisit-after" content="1 day">
      <meta name="language" content="Portuguese">
      <meta name="generator" content="N/A">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <title>Vanilla</title>
      <link rel="stylesheet" href="node_modules/bootstrap/compiler/bootstrap.css">
      <link rel="stylesheet" href="node_modules/font-awesome/css/font-awesome.css">
      <script src="node_modules/jquery/dist/jquery.js"></script>
      <script src="node_modules/popper.js/dist/popper.js"></script>
      <link rel="stylesheet" href="css/style.css">
   </head>
   <!-- ======================== MENU DO SITE ======================== -->
   <body>
      <div>
         <header>
            <nav>
               <div class="menu-icon">
                  <i class="fa fa-bars fa-2x"></i>
               </div>
               <div class="menu">
                  <div class="menu" id="menu1">
                     <ul>
                        <li><a href="#">Inicio</a></li>
                        <li><a href="#">Cardapio</a></li>
                     </ul>
                  </div>
                  <div id="logo-menu">
                     <img class="img-fluid" src="img/santo-pão-logo2.png">
                  </div>
                  <div class="menu" id="menu2">
                     <ul>
                        <li><a href="#">Sobre Nós</a></li>
                        <li><a href="#">Contato</a> </li>
                     </ul>
                  </div>
               </div>
            </nav>
            <script type="text/javascript">
               // Menu-toggle button
               
               $(document).ready(function() {
                   $(".menu-icon").on("click", function() {
                       $("nav ul").toggleClass("showing");
                   });
               });
               
               // Efeito do Scroll
               /*
               $(window).on("scroll", function() {
                   if($(window).scrollTop()) {
                       $('nav').addClass('black');
                   }
               
                   else {
                       $('nav').removeClass('black');
                   }
               })
               */
               
            </script>
            <!-- ======================== SLIDER DO SITE ======================== -->
            <div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
               <ol class="carousel-indicators">
                  <li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
                  <li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
                  <li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
               </ol>
               <div class="carousel-inner">
                  <div class="carousel-item active">
                     <img class="d-block w-100" src="img/slide_1.jpg" alt="First slide">
                  </div>
                  <div class="carousel-item">
                     <img class="d-block w-100" src="img/slide_2.jpg" alt="Second slide">
                  </div>
                  <div class="carousel-item">
                     <img class="d-block w-100" src="img/slide_3.jpg" alt="Third slide">
                  </div>
               </div>
               <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
               <span class="carousel-control-prev-icon" aria-hidden="true"></span>
               <span class="sr-only">Previous</span>
               </a>
               <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
               <span class="carousel-control-next-icon" aria-hidden="true"></span>
               <span class="sr-only">Next</span>
               </a>
            </div>
            <!-- ======================== FIM DO SLIDER DO SITE ======================== -->
         </header>
         <main>
         </main>
      </div>
   </body>
</html>

1 answer

1


Put the z-index in -1 that the layer of div #logo-menu where the image is not above the menu:

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
}
body {
    font-family: "Helvetica Neue",sans-serif;
    font-weight: lighter;
}
header {
    width: 100%;
}
nav {
    position: fixed;
    width: 100%;
    z-index: 5;
    background: #471e12;
}
nav ul {
    line-height: 68px;
    list-style: none;
    background: rgba(71, 30, 18, 0);
    overflow: hidden;
    color: #fff;
    text-align: center;
    margin: 0;
    padding: 0 40px 0 0;
    transition: 1s;
}
nav.black ul {
    background: #471e12;
}
nav ul li {
    display: inline-block;
    padding: 16px 40px;;
}
nav ul li a {
    text-decoration: none;
    color: #fff;
    font-size: 16px;
}
nav ul li a:hover {
    text-decoration: none;
    color: #fff;
    font-size: 16px;
}
.menu-icon {
    line-height: 60px;
    width: 100%;
    background: #471e12;
    text-align: right;
    box-sizing: border-box;
    padding: 15px 24px;
    cursor: pointer;
    color: #fff;
    display: none;
}
#logo-menu{
    position: fixed;
    margin-left: 0;
    margin-right: 0;
    width: 100%;
    height: 30%;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    float: top;
    z-index: -1;
}
#logo-menu img{
    width: 15%;

}
#menu1{
    float: left;
    z-index: 6;
}
#menu2{
    float: right;
    z-index: 6;
}
@media(max-width: 786px) {
    .logo {
        position: fixed;
        top: 0;
        margin-top: 16px;
    }
    nav ul {
        max-height: 0;
        background: #471e12;
    }
    nav.black ul {
        background: #471e12;
    }
    .showing {
        max-height: 34em;
    }
    nav ul li {
        box-sizing: border-box;
        width: 100%;
        padding: 24px;
        text-align: center;
    }
    .menu-icon {
        display: block;
    }
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">

<div>
         <header>
            <nav>
               <div class="menu-icon">
                  <i class="fa fa-bars fa-2x"></i>
               </div>
               <div class="menu">
                  <div class="menu" id="menu1">
                     <ul>
                        <li><a href="#">Inicio</a></li>
                        <li><a href="#">Cardapio</a></li>
                     </ul>
                  </div>
                  <div id="logo-menu">
                     <img class="img-fluid" src="https://www.cleverfiles.com/howto/wp-content/uploads/2016/08/mini.jpg">
                  </div>
                  <div class="menu" id="menu2">
                     <ul>
                        <li><a href="#">Sobre Nós</a></li>
                        <li><a href="#">Contato</a> </li>
                     </ul>
                  </div>
               </div>
            </nav>

  • Funciono! thank you very much, helped a lot.

Browser other questions tagged

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