DropDown位于其他元素css的顶部

时间:2016-12-05 21:05:49

标签: javascript jquery html css

我试过放dropdown,但他没有在其他元素之上。我试过放z-index但仍然没有运气。我已经制作了position: 'relative',但是当鼠标悬停在下拉按钮上时元素被推下来。

继承了网站http://jaysonvelagio.webprodigymedia.com/

<div id="believe-belong">
    <div class="site-width">
        <div class="two-col">
            <div class="two-col-one image">
                <img src="assets/image/dine.jpg" alt="CLICKTREP Dining Privileges" />
            </div><!-- .two-col-one.image -->

            <div class="two-col-two">
                <h3 class="green">Dine</h3>
                <p>Taste your favorite mouthwatering dish for less on restaurants/Café/Bakeshop of your choice all over the Metro. Take advantage of the regular discounts and perks whenever you visit our partners.</p>
                        <div class="dropdown">
                          <button class="dropbtn">partners in dine</button>
                          <div class="dropdown-content">
                            <a href="#">Link 1</a>
                            <a href="#">Link 2</a>
                            <a href="#">Link 3</a>
                          </div>
                        </div>  
            </div><!-- .two-col-two -->
        </div><!-- .row.two-col -->

    </div><!-- .site-width -->
</div><!-- #believe-belong -->


<div id="gray-back">
    <div class="site-width">
        <div class="two-col" >  
            <div class="two-col-two">
                <h3 class="green">Shop</h3>
                <p>Instant Discounts anytime from today’s best Shopping stores. <br>Like Toby’s Sport, RUNNR, Ideal Vision and a lot more. </p>
                <a href="clubmembers/blog.php" class="button">Partner Stores</a>    
            </div><!-- .two-col-two -->
            <div class="two-col-one image">
                <img src="assets/image/shop.jpg" alt="CLICKTREP Dining Privileges" />
            </div><!-- .two-col-one.image -->       
        </div><!-- .row.two-col -->

    </div><!-- .site-width -->
</div><!-- #believe-belong -->

1 个答案:

答案 0 :(得分:0)

我在网站上玩了你的代码,看起来你的问题比你想象的要复杂得多。

您不会获得该下拉菜单的原因是您有溢出:隐藏在具有类two-col的父div上。

现在,如果您尝试添加溢出:可见,它与整个DOM结构混淆,如您所见:

enter image description here

解决这个问题的唯一方法是添加溢出:div可见,看看如何重新排列结构。

更新:

我只用overflow-y:visible添加了另一个游戏。这次它不会弄乱UI,但会为该div添加一个滚动条。如果没关系,你可以继续这个。

.two-col {
   overflow-x: hidden;
   overflow-y: visible;
   position: relative;
}