gpt4 book ai didi

html - 无法让我的列表项居中

转载 作者:行者123 更新时间:2023-11-28 00:13:22 25 4
gpt4 key购买 nike

我有以下代码,我希望列表居中(现在它向左拉)。知道为什么吗?

<div class="row" style="width:100%;text-align:center;">
<div class ="banner span12" style="padding-top: 0px; padding-bottom:0px;text-align:center;">
<p style="font-size:18px;padding-top:6px;"> Or Start Browsing the Library ... </p></center>
</div>
<br>
<br>
<ul class="nav nav-pills" style="text-align:center;">
<li class="active" style="text-align:center;">
<a href ="#"> Library1 </a>
</li>
<li>
<a href ="#"> Library2 </a>
</li>
<li>
<a href ="#"> Library3 </a>
</li>
</ul>

导航丸 CSS:

.nav-pills > li > a {
padding-top: 8px;
padding-bottom: 8px;
margin-top: 2px;
margin-bottom: 2px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
.nav-pills > .active > a,
.nav-pills > .active > a:hover {
color: #ffffff;
background-color: #0088cc;
}

最佳答案

给它一个宽度并应用边距:0 auto;

ul.nav-pills {
width: 300px;
margin: 0 auto;
}

<div class="row" style="width:100%;text-align:center;">
<div class ="banner span12" style="padding-top: 0px; padding-bottom:0px;text-align:center;">
<p style="font-size:18px;padding-top:6px;"> Or Start Browsing the Library ... </p></center>
</div>
<br>
<br>
<ul class="nav nav-pills" style="text-align:center;">
<li class="active" style="text-align:center;">
<a href ="#"> Library1 </a>
</li>
<li>
<a href ="#"> Library2 </a>
</li>
<li>
<a href ="#"> Library3 </a>
</li>
</ul>

关于html - 无法让我的列表项居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13807021/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com