按钮下的浮动模态窗口

时间:2012-03-21 07:29:51

标签: css

我需要显示一个通知模式窗口..但由于它的流畅布局,位置在更大的屏幕上变化。 如何将模态窗口定位在链接下方,如图像中所示。我希望它在准确的位置。我该怎么做呢? enter image description here

1 个答案:

答案 0 :(得分:2)

This should work as a base for you.

<强> HTML

<div class="notificaton-bar">
    <div class="notice">Notification
        <div>
            Here is the applicable note.
        </div>    
    </div>
</div>

<强> CSS

.notificaton-bar {
    background-color: #999999;
    padding: 0 10px;
}

.notice {
    position: relative;
    display: inline-block;
    background-color: inherit;
    font-size: 1.5em;
    min-width: 140px;
    padding: 10px 5px;
    text-align: center;
}

.notice div {
    display: none;
    width: 130px;
    padding: 10px;
    font-size: .75em;
    text-align: left;
    background-color: inherit;
    border-radius: 10px;
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -75px;
    margin-top: 10px;    
}

.notice div:before {
    content: '';
    display: block;
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 11px solid #999999;
    position: absolute;
    top: -10px;
    left: 50%;
    margin-left: -10px;
}

.notice:hover div {
    display: block;
}