为什么下拉列表会压低下方的div

时间:2011-11-29 15:49:31

标签: jquery html css xhtml

我有page,如果你滚动到中间,你会看到一个Select Shipping Method下拉菜单,如果你点击它。它将推送Review Terms & Conditions链接...这是我的代码

HTML

<div class="shipping-box lf">
<div class="ship-box1 lf">
    <div class="sel-ship lf">
        <div class="ss lf">
            <span class="lf">Select Shipping Method</span>
            <a class="ship-btn" href="#"></a>
        </div>
        <div class="dropdown lf" style="display:none;">
            <ul>
                <li class="ss-1 lf">1 Location</li>
                <li class="ss-2 lf">2 Location</li>
            </ul>       
        </div>  
    </div>
    <div class="terms lf">Review Terms & Conditions</div>
</div>

CSS

.shipping-box {
    height: 65px;
    padding-top: 0;
    position: relative;
    width: 700px;
}

.lf {
    float: left;
}

.ship-box1 {
    width: 220px;
}

.sel-ship {
    width: 220px;
}

.terms {
    color: #009900;
    font-family: "helvetica neue";
    font-size: 12px;
    padding-left: 20px;
    text-decoration: underline;
    text-transform: uppercase;
    width: 200px;
}

JQUERY

$('.ship-box1, .ship-btn').click(function () {
    $(this).parents('.sel-ship').find('.dropdown').slideToggle();
    $(this).parents('.ss').toggleClass('ship-btn:hover');
    return false;
});

有关如何确保术语链接保持不变的任何想法

3 个答案:

答案 0 :(得分:2)

这将为您解决:

.sel-ship { position: relative; }
.dropdown { position: absolute; top: 25px; }

答案 1 :(得分:1)

尝试添加此内容:

.sel-ship{
    position:absolute;
}
.terms{
    margin-top:30px;
}

答案 2 :(得分:1)

.sel-ship班级position:absolute;设置.terms班级margin-top:35px;