我有以下HTML,我试图将span
内的ul li
标签居中对齐。
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">
<img src="../">
</a>
<ul class="nav navbar-nav">
<li>
<span>Need to Center align</span>
</li>
</ul>
</div>
</div>
</nav>
答案 0 :(得分:1)
<li class=“text-center”><span>...centered text</span></li>
答案 1 :(得分:0)
如果您将类名添加到li
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">
<img src="https://www.w3schools.com/images/w3schools_green.jpg" height=500, width= 400>
</a>
<ul class="nav navbar-nav">
<li class="this">
<span>Need to Center align</span>
</li>
</ul>
</div>
</div>
</nav>
然后可以使用CSS。
.this {
text-align: center;
}