html - 没有水平滚动条的溢出屏幕自定义导航栏(引导)
问题描述
我的页面上有一个自定义navbar
(引导程序)。
<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>
这是navCustom
和的CSS navComp
:
@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);
}
我的问题是浏览器的尺寸很薄。
浏览器navbar
右边距溢出,但不出现滚动条。
滚动条仅在divs
文本Test
在右边距溢出时出现。
解决方案
最后我想通了。
.fixed-top
来自 Bootstrap 有position: fixed
这就是我的元素不触发滚动条的原因。
position: sticky !important;
我通过添加到我的修复它.navCustom
这让我稍微改变了我的css和结构,但至少我得到了我想要的。
推荐阅读
- java - Java GUI 从文件中搜索单词然后继续
- node.js - 部署到 heroku [错误:spawn babel-node ENOENT]
- sql - 在 phpMyadmin 中导入 sql 文件时出错
- unit-testing - 如何在玩笑中检查包含某些键的对象?
- ruby-on-rails - devise-security gem 未找到设计控制器,rails 5.2
- javascript - setState 不适用于数组 reactjs
- list - 用折叠拆分Haskell中的列表?
- c# - ControlTemplate DataGridColumnHeader 控件在列外可见
- azure - Docker swarm 部署到 Azure
- javascript - 使用带有 Next JS 路由的 React 路由器