下拉菜单隐藏在图片后面

时间:2018-09-25 07:43:46

标签: html css twitter-bootstrap drop-down-menu

当向下滚动导航栏时,“我的下拉菜单”隐藏在图像后面(猫头鹰食肉动物),然后悬停正常工作。

仅在显示图像的上方区域显示问题。

我尝试通过给定z-index。通过为导航栏提供比图像滑块更高的值。但这是行不通的。

我也尝试了溢出值。

我给了溢出:可见;到导航栏,但仍然不可见。

错误下拉菜单的屏幕截图

Dropdown in not showing completely

jQuery(document).ready(function($) {
    $("#owl-demo").owlCarousel({
        navigation : true,
        slideSpeed : 300,
        paginationSpeed : 500,
        items: 1,
        singleItem: true,
        autoPlay : 4000
    });
});

$('body').on('mouseenter mouseleave','.dropdown',function(e){
    var _d=$(e.target).closest('.dropdown');
    _d.addClass('show');
    setTimeout(function(){
        _d[_d.is(':hover')?'addClass':'removeClass']('show');
        $('[data-toggle="dropdown"]', _d).attr('aria-expanded',_d.is(':hover'));
    },300);
});
/*sticky header position*/
.sticky.is-sticky {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    z-index: 999;
    width: 100%;
}

header {
    background: transparent !important;

}

/*body {*/
    /*min-height: 1200px;*/
/*}*/
nav {
    background-color: #000000;
    min-height: 85px;
    color: white;
    opacity: 0.7;
}

.dropdown:hover>.dropdown-menu {
    display: block;
    overflow: visible;
    z-index: 1000;
    position: inherit;
    margin-top: 10%;
}

nav ul li a  {
    color:  white !important;
}

.top-div {
    font-size: 14px;
    background-color: black;
    color: white;
    padding-top: 10px;
}

.top-div p .fa-map-marker{
    margin-left: 4%;
}

.top-div p i {
    margin-right: 0.5%;
    margin-left: 3%;
    color: #c6b52d;
}

/* Ow; Slider CSS*/

#owl-demo {
    z-index: 30;
}

.owl-wrapper {
    positon: relative;
}

.owl-controls {
    position: absolute;
    bottom: 10px;
    left: 0;
    right: 0;
    margin-left: auto;
    margin-right: auto;
}

.owl-theme .owl-controls .owl-page span {
    background: #fff !important;
}

.owl-img {
    width: 100%;
}

.owl-text-overlay {
    position: absolute;
    text-align: center;
    width: 60%;
    top: 50%;
    transform: translateY(-50%);
    left: 0;
    right: 0;
    margin-left: auto;
    margin-right: auto;
    color: #fff;
    background-color: rgba(0, 0, 0, 0.4);
    background: rgba(0, 0, 0, 0.4);
    padding-bottom: 20px;
    font-family: "Open Sans", sans-serif;
    border-radius: 15px 50px 30px 5px;
}
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Imagine</title>
    <link href="https://fonts.googleapis.com/css?family=Ubuntu:300,400,800" rel="stylesheet">
    <link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/owl-carousel/1.3.3/owl.carousel.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/owl-carousel/1.3.3/owl.theme.min.css">

    <script src="https://cdnjs.cloudflare.com/ajax/libs/owl-carousel/1.3.3/owl.carousel.min.js"></script>
   
</head>
<body>
<!--top header-->
<header>
    <!--most top info -->
    <!--<div style="height: 40px; background: red"></div>-->
    
    <!-- End most top info -->

    <nav class="navbar  navbar-expand-lg navbar-light top-navbar" data-toggle="sticky-onscroll">
        <div class="container">
            <a class="navbar-brand" href="#">
                <img src="assets/images/Logo-white.png" height="70" alt="">
            </a>
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>

            <div class="collapse navbar-collapse justify-content-end" id="navbarSupportedContent">
                <ul class="navbar-nav pull-right">
                    <li class="nav-item">
                        <a class="nav-link active" href="#">Home</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="about-us.html">Who We Are</a>
                    </li>
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                            Dropdown link
                        </a>
                        <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
                            <a class="dropdown-item" href="#">Action</a>
                            <a class="dropdown-item" href="#">Another action</a>
                            <a class="dropdown-item" href="#">Something else here</a>
                        </div>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="#">Support & Service</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="#">Contact Us</a>
                    </li>

                </ul>

            </div>
        </div>
    </nav>

</header>


<div class="owl-carousel owl-theme" id="owl-demo">
    <div>
        <div class="owl-text-overlay hidden-xs">
            <h2 class="owl-title">Arrow</h2>
            <p class="owl-caption hidden-sm">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent iaculis purus vel enim suscipit, vitae volutpat ante scelerisque. Pellentesque blandit malesuada dui, sed aliquet risus molestie non.</p>
        </div><img class="owl-img" src="https://res.cloudinary.com/jbennett45/image/upload/v1474628443/arrow_dqnmmf.jpg"></div>
    <div>
        <div class="owl-text-overlay hidden-xs">
            <h2 class="owl-title">Flash</h2>
            <p class="owl-caption hidden-sm">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent iaculis purus vel enim suscipit, vitae volutpat ante scelerisque. Pellentesque blandit malesuada dui, sed aliquet risus molestie non.</p>
        </div><img class="owl-img" src="https://res.cloudinary.com/jbennett45/image/upload/v1474628444/flash_pxythx.jpg"></div>
</div>

4 个答案:

答案 0 :(得分:2)

z-index添加到nav

z-index属性指定元素的堆叠顺序。

Reference

jQuery(document).ready(function($) {
    $("#owl-demo").owlCarousel({
        navigation : true,
        slideSpeed : 300,
        paginationSpeed : 500,
        items: 1,
        singleItem: true,
        autoPlay : 4000
    });
});

$('body').on('mouseenter mouseleave','.dropdown',function(e){
    var _d=$(e.target).closest('.dropdown');
    _d.addClass('show');
    setTimeout(function(){
        _d[_d.is(':hover')?'addClass':'removeClass']('show');
        $('[data-toggle="dropdown"]', _d).attr('aria-expanded',_d.is(':hover'));
    },300);
});
/*sticky header position*/
.sticky.is-sticky {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    z-index: 999;
    width: 100%;
}

header {
    background: transparent !important;

}

/*body {*/
    /*min-height: 1200px;*/
/*}*/
nav {
    background-color: #000000;
    min-height: 85px;
    color: white;
    opacity: 0.7;
    z-index: 999999; //Add this
}

.dropdown:hover>.dropdown-menu {
    display: block;
    overflow: visible;
    z-index: 1000;
    position: inherit;
    margin-top: 10%;
}

nav ul li a  {
    color:  white !important;
}

.top-div {
    font-size: 14px;
    background-color: black;
    color: white;
    padding-top: 10px;
}

.top-div p .fa-map-marker{
    margin-left: 4%;
}

.top-div p i {
    margin-right: 0.5%;
    margin-left: 3%;
    color: #c6b52d;
}

/* Ow; Slider CSS*/

#owl-demo {
    z-index: 30;
}

.owl-wrapper {
    positon: relative;
}

.owl-controls {
    position: absolute;
    bottom: 10px;
    left: 0;
    right: 0;
    margin-left: auto;
    margin-right: auto;
}

.owl-theme .owl-controls .owl-page span {
    background: #fff !important;
}

.owl-img {
    width: 100%;
}

.owl-text-overlay {
    position: absolute;
    text-align: center;
    width: 60%;
    top: 50%;
    transform: translateY(-50%);
    left: 0;
    right: 0;
    margin-left: auto;
    margin-right: auto;
    color: #fff;
    background-color: rgba(0, 0, 0, 0.4);
    background: rgba(0, 0, 0, 0.4);
    padding-bottom: 20px;
    font-family: "Open Sans", sans-serif;
    border-radius: 15px 50px 30px 5px;
}
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Imagine</title>
    <link href="https://fonts.googleapis.com/css?family=Ubuntu:300,400,800" rel="stylesheet">
    <link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/owl-carousel/1.3.3/owl.carousel.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/owl-carousel/1.3.3/owl.theme.min.css">

    <script src="https://cdnjs.cloudflare.com/ajax/libs/owl-carousel/1.3.3/owl.carousel.min.js"></script>
   
</head>
<body>
<!--top header-->
<header>
    <!--most top info -->
    <!--<div style="height: 40px; background: red"></div>-->
    
    <!-- End most top info -->

    <nav class="navbar  navbar-expand-lg navbar-light top-navbar" data-toggle="sticky-onscroll">
        <div class="container">
            <a class="navbar-brand" href="#">
                <img src="assets/images/Logo-white.png" height="70" alt="">
            </a>
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>

            <div class="collapse navbar-collapse justify-content-end" id="navbarSupportedContent">
                <ul class="navbar-nav pull-right">
                    <li class="nav-item">
                        <a class="nav-link active" href="#">Home</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="about-us.html">Who We Are</a>
                    </li>
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                            Dropdown link
                        </a>
                        <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
                            <a class="dropdown-item" href="#">Action</a>
                            <a class="dropdown-item" href="#">Another action</a>
                            <a class="dropdown-item" href="#">Something else here</a>
                        </div>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="#">Support & Service</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="#">Contact Us</a>
                    </li>

                </ul>

            </div>
        </div>
    </nav>

</header>


<div class="owl-carousel owl-theme" id="owl-demo">
    <div>
        <div class="owl-text-overlay hidden-xs">
            <h2 class="owl-title">Arrow</h2>
            <p class="owl-caption hidden-sm">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent iaculis purus vel enim suscipit, vitae volutpat ante scelerisque. Pellentesque blandit malesuada dui, sed aliquet risus molestie non.</p>
        </div><img class="owl-img" src="https://res.cloudinary.com/jbennett45/image/upload/v1474628443/arrow_dqnmmf.jpg"></div>
    <div>
        <div class="owl-text-overlay hidden-xs">
            <h2 class="owl-title">Flash</h2>
            <p class="owl-caption hidden-sm">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent iaculis purus vel enim suscipit, vitae volutpat ante scelerisque. Pellentesque blandit malesuada dui, sed aliquet risus molestie non.</p>
        </div><img class="owl-img" src="https://res.cloudinary.com/jbennett45/image/upload/v1474628444/flash_pxythx.jpg"></div>
</div>

答案 1 :(得分:1)

您需要将getOrElse添加到 scala> map1 ++ map2.map{ case (k,v: Double) => k -> (v + map1.getOrElse(k,0.0)) } res2: scala.collection.immutable.Map[Int,Double] = Map(5 -> 6.0, 1 -> 4.5, 6 -> 1.23, 2 -> 3.0, 7 -> 3.0, 3 -> 5.0, 4 -> 8.2 ) 类中。这是下拉菜单的整体父项。

只是一个旁注:您可能要更改子菜单项的颜色文本,因为它们目前是白色的,与背景图像匹配并且不可见。

这里正在工作:https://jsfiddle.net/Ly06krt3/20/

答案 2 :(得分:0)

只需将z-index添加到下拉列表中,它应该大于图片及其父对象的z-index(如果有)。

答案 3 :(得分:0)

如果Z索引不起作用,则另一种可能性是溢出设置为隐藏。刚才我发生了什么。