使用引导轮播时,CSS下拉菜单消失

g

我有一个下拉式导航菜单(使用w3schools的css),可以正常工作,直到紧接着放置轮播。然后下拉列表不再显示,我也不知道为什么。我是CSS HTML ..的新手,所以找不到我的问题的解决方案。我已经更改了Z-index和多个类的位置,但不能解决问题。每当我删除引导CSS链接时,下拉菜单就会再次起作用。你有什么建议吗?谢谢!

ps:我把所有代码都放了,抱歉,如果我添加了超出要求的部分,这是我第一次发布

/* CSS Document */

* {
  box-sizing: border-box;
  font-family: Arial, Helvetica, sans-serif;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
}

.background-image {
  background-image: linear-gradient(rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0)), url("../img/header.jpg");
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  position: relative;
  width: 100%;
}

.header-text {
  text-align: center;
  color: white;
  padding: 30px;
}


/* Add a black background color to the top navigation */

.topnav {
  background-color: #333;
  overflow: hidden;
}


/* Style the links inside the navigation bar */

.topnav a {
  float: left;
  display: block;
  color: #f2f2f2;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
  font-size: 17px;
}


/* Change the color of links on hover */

.topnav a:hover {
  background-color: #1C8CE8;
  text-decoration: none;
  color: black;
}


/* Add an active class to highlight the current page */

.activenav {
  background-color: #4F47E1;
  color: white;
}


/* Hide the link that should open and close the topnav on small screens */

.topnav .icon {
  display: none;
}


/* Dropdown container - needed to position the dropdown content */

.dropdown {
  float: left;
  overflow: hidden;
}


/* Style the dropdown button to fit inside the topnav */

.dropdown .dropbtn {
  font-size: 17px;
  border: none;
  outline: none;
  color: white;
  padding: 14px 16px;
  background-color: inherit;
  font-family: inherit;
  margin: 0;
}


/* Style the dropdown content (hidden by default) */

.dropdown-content {
  display: none;
  position: absolute;
  background-color: #f9f9f9;
  min-width: 160px;
  box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
}


/* Style the links inside the dropdown */

.dropdown-content a {
  float: none;
  color: black;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
  text-align: left;
}


/* Add a dark background on topnav links and the dropdown button on hover */

.topnav a:hover,
.dropdown:hover .dropbtn {
  background-color: #555;
  color: white;
}


/* Add a grey background to dropdown links on hover */

.dropdown-content a:hover {
  background-color: #ddd;
  color: black;
}


/* Show the dropdown menu when the user moves the mouse over the dropdown button */

.dropdown:hover .dropdown-content {
  display: block;
}

.carousel {
  max-width: 100% !important;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.carousel-inner>.item>img {
  height: 600px!important;
  width: 100%;
}


/* When the screen is less than 600 pixels wide, hide all links, except for the first one ("Home"). Show the link that contains should open and close the topnav (.icon) */

@media screen and (max-width: 600px) {
  .topnav a:not(:first-child),
  .dropdown .dropbtn {
    display: none;
  }
  .topnav a.icon {
    float: right;
    display: block;
  }
}


/* The "responsive" class is added to the topnav with JavaScript when the user clicks on the icon. This class makes the topnav look good on small screens (display the links vertically instead of horizontally) */

@media screen and (max-width: 600px) {
  .topnav.responsive {
    position: relative;
  }
  .topnav.responsive a.icon {
    position: absolute;
    right: 0;
    top: 0;
  }
  .topnav.responsive a {
    float: none;
    display: block;
    text-align: left;
  }
  .topnav.responsive .dropdown {
    float: none;
  }
  .topnav.responsive .dropdown-content {
    position: relative;
  }
  .topnav.responsive .dropdown .dropbtn {
    display: block;
    width: 100%;
    text-align: left;
  }
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>

  <nav class="topnav" id="myTopnav">
    <a href="#home" class="activenav">Home</a>
    <div class="dropdown">
      <button class="dropbtn">Products 
            <i class="fa fa-caret-down"></i>
        </button>
      <div class="dropdown-content">
        <a href="#">Make</a>
        <a href="#">Model</a>
        <a href="#">Year</a>
      </div>
    </div>
    <a href="#news">News</a>
    <a href="#about">About</a>
    <a href="#contactus">Contact us</a>
    <a href="javascript:void(0);" class="icon" onclick="Functionnav()"><i class="fa fa-bars"></i></a>
  </nav>
  <section id="myCarousel" class="carousel slide" data-ride="carousel">
    <!-- Indicators -->
    <ol class="carousel-indicators">
      <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
      <li data-target="#myCarousel" data-slide-to="1"></li>
      <li data-target="#myCarousel" data-slide-to="2"></li>
    </ol>

    <!-- Wrapper for slides -->
    <div class="carousel-inner">
      <div class="item active">
        <img src="img/img1slideshow.jpg" alt="Chania">
        <div class="carousel-caption">
          <h3>title</h3>
          <p>paragraph</p>
        </div>
      </div>

      <div class="item">
        <img src="img/img2slideshow.jpg" alt="Chania">
        <div class="carousel-caption">
          <h3>title</h3>
          <p>paragraph</p>
        </div>
      </div>

      <div class="item">
        <img src="img/img3slideshow.jpg" alt="Chania">
        <div class="carousel-caption">
          <h3>title</h3>
          <p>paragraph</p>
        </div>
      </div>

    </div>

TanBir开发人员

菜单包装中css属性溢出的问题使用下面的代码,希望对您有所帮助

.dropdown {overflow: initial;}
.topnav {
   overflow: visible;
   width: 100%;
   height: 53px;
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

悬停上的下拉菜单消失(使用引导程序)

来自分类Dev

下拉菜单在悬停时消失

来自分类Dev

将鼠标移到菜单本身时,下拉菜单消失

来自分类Dev

使用CSS在鼠标悬停时创建下拉菜单

来自分类Dev

使用CSS在鼠标悬停时创建下拉菜单

来自分类Dev

使用css在悬停时扩展下拉菜单

来自分类Dev

悬停在项目上时,CSS停止下拉菜单不会消失

来自分类Dev

将鼠标悬停在第二项上时,简单的CSS下拉菜单消失

来自分类Dev

在下拉菜单上悬停时,jQuery悬停下拉菜单消失

来自分类Dev

下拉菜单快速消失

来自分类Dev

更改焦点时防止微调框下拉菜单消失

来自分类Dev

当鼠标不在链接上时,下拉菜单消失

来自分类Dev

鼠标悬停时,下拉菜单消失

来自分类Dev

下拉菜单在悬停时消失(博客)

来自分类Dev

引导轮播视频

来自分类Dev

引导轮播问题

来自分类Dev

引导轮播崩溃

来自分类Dev

引导程序下拉菜单

来自分类Dev

引导程序下拉菜单

来自分类Dev

当使用正确对齐的引导字形时,内联下拉菜单<li>

来自分类Dev

单击项目时,使用下拉菜单引导程序编辑列表项目

来自分类Dev

单击下拉菜单按钮时的引导程序打开链接

来自分类Dev

下拉菜单文本对齐,css 工作但引导程序失败?

来自分类Dev

CSS下拉菜单

来自分类Dev

Animate.css使用下拉菜单

来自分类Dev

我无法使用CSS下拉菜单

来自分类Dev

我无法使用CSS下拉菜单

来自分类Dev

使用CSS的水平下拉菜单

来自分类Dev

使用CSS的下拉菜单:target伪