【发布时间】:2014-04-30 21:45:48
【问题描述】:
我是一名 HTML/CSS 初学者,因此遇到以下问题:此 Bootstrap 模式中的列表项(带有图标)彼此之间正确左对齐。但是,我希望整个列表出现在模式的中心。
为了让列表项正确左对齐,我的 CSS 中有这个:
.modal-list > li > a {
color:#333;
text-decoration: none;
list-style: none;
display: block;
text-align: left;
}
这是(我认为是)相关的 HTML:
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Sign up or log in using OpenID</h4>
</div>
<div class="modal-body">
At this time, CloudSim is in beta and by invitation only. If you have received an invite, pick a login option below.
<!--OpenID options -->
<ul class="dropdown-menu-modal" style="list-style-type:none;">
<li>
<a href="/auth/google"><img class="inline-block"
alt="Google" width="46" src="/img/icons/google.svg"/> Google</a>
</li>
<li>
<a href="/auth/yahoo"><img class="inline-block"
alt="Yahoo" width="46" src="/img/icons/yahoo.svg"> Yahoo</a>
</li>
<li>
<a href="/auth/aol"><img class="inline-block"
alt="AOL" width="46" src="/img/icons/aol.svg"> AOL</a>
</li>
<li>
<a href="/auth/openid"><img class="inline-block"
alt="OpenId" width="46" src="/img/icons/openid.svg"> OpenId</a>
</li>
</ul>
<!-- end here -->
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
</div>
</div>
</div>
</div>
<!-- end of modal -->
我没有足够的“声誉”来发布图片,所以这里有一个链接,可以看到它目前的样子:http://imgur.com/c7mrjfV
【问题讨论】:
-
你也可以添加你的html
-
已添加!让我知道是否缺少某些东西:)
-
可以尝试向 ul 添加特定宽度并像这样使用自动边距
.dropdown-menu-modal{width:100px;margin:0 auto;} -
哦,确实有效,谢谢!你认为这会扰乱小型设备上布局的响应能力吗?
-
由于宽度只有 100 像素,我认为它不会在较小的设备上搞砸
标签: html css twitter-bootstrap modal-dialog