我正在使用Bootstrap 4.1,但在获取正确的工作理由时遇到了问题。基本上,我有一个导航栏,可启动带有选项卡的模态对话框。最右边的选项卡是一个下拉菜单。最右边的下拉菜单是我要纠正的菜单。到目前为止,这是我尝试过的:
ml-auto
标签的代码部分中添加了<li class='nav-item active dropdown'>
,其注释为:“模态-下拉” mr-auto
标签的代码部分中添加了<ul class="nav nav-tabs mr-auto" role="tablist">
,其注释为:“模态-下拉” justify-content-end
标签的代码部分中添加了<li class="nav-item active dropdown justify-content-end">
,其注释为:“模态-下拉” ml-auto
标签的代码部分中添加了<li class="nav-item active dropdown justify-content-end ml-auto">
,其注释为:“模态-下拉” <div class="d-flex flex-row-reverse bd-highlight">, <div class="d-flex justify-content-end">, <div class="d-flex align-items-end">, <div class="align-self-end">
但是没有任何作用。
还有其他人使用Bootstrap 4.1完成此操作吗?
我的代码可在JSFiddle上找到:https://jsfiddle.net/tsmolskow/jm19hu3t/66/
我的HTML代码如下:
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header"></div>
</div>
</div>
<!-- Navigation Bar -->
<nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
<a class="navbar-brand" href="#">SharePointGypsy.com</a>
<button class="navbar-toggler collapsed" aria-expanded="false" aria-controls="navbar" aria-label="Toggle navigation" type="button" data-toggle="collapse" data-target="#navbar">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse" id="navbar">
<ul class="nav navbar-nav navbar-right">
<li class="nav-item active">
<a class="nav-link" id="Departments" data-toggle="modal" data-target="#MyNNSModal">Departments</a></li>
<li class="nav-item active">
<a class="nav-link" id="Resources" data-toggle="modal" data-target="#MyNNSModal">Resources</a></li>
<li class="nav-item active">
<a class="nav-link" id="Procedures" data-toggle="modal" data-target="#MyNNSModal">Procedures</a></li>
<li class="nav-item active">
<a class="nav-link" id="News" data-toggle="modal" data-target="#MyNNSModal">News</a></li>
</ul>
</div>
</nav>
<!-- Modal -->
<div tabindex="-1" class="modal fade" id="MyNNSModal" role="dialog" aria-hidden="true" aria-labelledby="exampleModalLabel">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<div class="tabbable">
<!-- Nav Tabs, Modal Nav Bar -->
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item active">
<a class="nav-link active" href="#aDepartments" data-toggle="tab">Departments</a></li>
<li class="nav-item active">
<a class="nav-link" href="#aResources" data-toggle="tab">Resources</a></li>
<li class="nav-item active">
<a class="nav-link" href="#aProcedures" data-toggle="tab">Procedures</a></li>
<li class="nav-item active">
<a class="nav-link" href="#aNews" data-toggle="tab">News</a></li>
</ul>
</div>
<div class="d-flex align-self-end">
<a class="dropdown-toggle" data-toggle="dropdown" id="navbardrop">
<img src="Images/KoKoPelli.jpg" class="profile-picture"/>
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Newsfeed</a></li>
<li><a class="dropdown-item" href="#">One Drive</a></li>
<li><a class="dropdown-item" href="#">Sites</a></li>
</ul>
</div>
<!-- Close Button -->
<div>
<button class="close" aria-label="Close" type="button" data-dismiss="modal"><span aria-hidden="true"><img class="close-button" src="/sites/dscott/tmfds/SiteAssets/Images/CloseButton.png" alt=""/> </span> </button> </div>
</div>
<!-- Panes -->
<div class="modal-body">
<div class="tab-content">
<!-- Tab Panes -->
<div class="tab-pane active" id="aDepartments">
<p>
<b>Departments:</b>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Impedit iusto nulla aperiam blanditiis ad consequatur in dolores culpa, dignissimos, eius non possimus fugiat. Esse ratione fuga, enim, ab officiis totam.</p>
</div>
<div class="tab-pane" id="aResources">
<p>
<b>Resources:</b>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Impedit iusto nulla aperiam blanditiis ad consequatur in dolores culpa, dignissimos, eius non possimus fugiat. Esse ratione fuga, enim, ab officiis totam.</p>
</div>
<div class="tab-pane" id="aProcedures">
<p>
<b>Procedures:</b>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Impedit iusto nulla aperiam blanditiis ad consequatur in dolores culpa, dignissimos, eius non possimus fugiat. Esse ratione fuga, enim, ab officiis totam.</p>
</div>
<div class="tab-pane" id="aNews">
<p>
<b>News:</b>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Impedit iusto nulla aperiam blanditiis ad consequatur in dolores culpa, dignissimos, eius non possimus fugiat. Esse ratione fuga, enim, ab officiis totam.</p>
</div>
</div>
</div>
<!-- Footer -->
<div class="modal-footer"></div>
</div>
</div>
</div>
答案 0 :(得分:1)
可以尝试吗? CSS:
.tabbable {
width: 100%;
}
.tabbable > ul.nav.nav-tabs {
display: table;
}
.tabbable > ul.nav.nav-tabs > li {
width: auto;
display: table-cell;
}
.tabbable > ul.nav.nav-tabs > li:last-child {
width: 100%;
vertical-align: bottom;
}
.tabbable > ul.nav.nav-tabs > li:last-child ul.dropdown-menu {
width: 100%;
}