css - 按钮下的 float 模态窗口

标签 css

我需要显示一个通知模式窗口。但是由于它是流体布局,因此位置会在更大的屏幕上发生变化。 我如何将模态窗口定位在链接下方,如图所示。我希望它处于准确的位置。我该如何去做呢? enter image description here

最佳答案

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;
}

关于css - 按钮下的 float 模态窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9800279/

相关文章:

php - html/CSS 格式中的小错误卡住 PHP 生成的 SQL 表中的第一列

html - 表格递归 html 渲染的解释

jquery - body 点击隐藏元素

javascript - 默认展开第一个菜单项并为背景着色

css - 带有下拉菜单的选项卡在现代浏览器中悬停时不会保持高度

css - iframe的溢出问题

css - 我在哪里可以获得元素的默认 css 设置列表?

html - 为什么我的 <ul> 没有扩展宽度来覆盖所有 <li>?

php - 限制最大高度的文本

javascript - 为 parent 的 parent 添加类(class)