html - 没有水平滚动条的溢出屏幕自定义导航栏( Bootstrap )

标签 html css twitter-bootstrap

我的页面上有一个自定义的 navbar(bootstrap)。

<nav class='navbar fixed-top navCustom '>

    <div class='navComp'>

        <input class='dateStyle' id='dateChart' type='date' value='" . $now . "'/>

        <button id='refreshBtn' class='refreshStyle' type='button' name='refresh'>Refresh</button>

        <form style='display:inline' method='post' action=''>
            <button id='logout' class='logoutStyle' type='submit' name='logout'>Log Out</button>
        </form>

    </div>

</nav>

这是 navCustomnavComp 的 css:

@media (min-width:600px) {

    .navCustom{
        justify-content: center !important;
    }

}

.navCustom{
    margin-top: -1px;
    height: 33px;
    white-space: nowrap;
}

.navComp{
    position: absolute;
    text-align: center;
    border-style: solid;
    border-color: #dadada;
    border-width: 1px;
    border-radius: 3px;
    background-color: #fafafa;
    padding-left:5px;
    padding-right:5px;
    box-shadow:0 0px 2px rgba(0, 0, 0, 0.1);
}

我的问题是浏览器太小了。

1

navbar 溢出在浏览器的右边缘,但没有出现滚动条。

滚动条仅在 div with text Test overflow on the right margin 时出现。

最佳答案

我终于明白了。

Bootstrap 的

.fixed-topposition: fixed 这就是我的元素没有触发滚动条的原因。

我通过将 position: sticky !important; 添加到我的 .navCustom 中来修复它

这让我稍微改变了我的 css 和结构,但至少我得到了我想要的。

关于html - 没有水平滚动条的溢出屏幕自定义导航栏( Bootstrap ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53516854/

相关文章:

javascript - 垂直对齐

html - 如何使用 css 或 bootstrap 定义图像的大小

html - 链接多个html页面

javascript - 滚动元素时的动画鼠标效果

css - 开发和测试打印样式表的更快方法(避免每次打印预览)?

html - 在一个 div 中重叠 div

css - Bootstrap 3 流体网格问题

javascript - 用父链接标题的 "href"包裹文章中的每个图像

显示先前选项卡内容的 JQuery 选项卡

仅 jQuery 移动滑动内容