我试过了:
<option selected >Tamil</option>
但是,它都不起作用。这是Nav标记和CSS文件: HTML:
‘.text-center’ on the li tags, inline
and:
li {
text-align: center;
}
‘justify-content-center’ on ul tag, inline
and
.ul {
justify-content: center;
}
Put the ul inside:
<div class="row">
<div class="col text-center”>
</div>
</div>
萨斯/ CSS
<nav class="navbar navbar-expand-md navbar-light bg-light fixed-top">
<div class="container">
<a class="navbar-brand" href="#">Brand Here</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarsExampleDefault">
<!-- ul starts here -->
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="http://example.com" id="dropdown01" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dropdown</a>
<div class="dropdown-menu" aria-labelledby="dropdown01">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
</ul>
<!-- ul ends here -->
</div>
</div><!-- container placed within <nav> tag -->
</nav>
任何帮助将不胜感激。 TIA
答案 0 :(得分:1)
要将导航栏内容集中在Bootstrap V4中,请使用flex-grow: 1;
它允许元素展开100%,使用justify-content: center;
属性将项目对齐到中心。
@media (min-width: 992px){
.navbar-expand-lg .navbar-nav {
flex-grow: 1;
justify-content: center;
}
}
答案 1 :(得分:0)
谢谢Satheesh,你让我走上了正确的道路。我在我的Sass文件中逐字尝试了你的解决方案,但由于某种原因,它没有工作。然后我刚补充说:
body {
padding-top: 56px;
nav .container {
max-width: 1374px;
.navbar-brand {
color: $blue-text !important;
}
/* added from your solution */
.navbar-nav {
flex-grow: 1;
justify-content: center;
}
}
}