2

次のコードがあり、リストを中央に配置します (現在は左に引っ張られます)。理由はありますか?

<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>

nav-丸薬 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;
}
4

1 に答える 1

2

幅を指定して margin: 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>
于 2012-12-10T18:40:00.600 に答える