我非常喜欢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
答案 0 :(得分:0)
您可以给出100%的宽度,然后将文本与中心对齐。
这将是响应式的,因此您无需担心添加特定宽度。
尝试添加这两行CSS
.modal-list > li > a {
color:#333;
text-decoration: none;
list-style: none;
display: block;
text-align: left;
width: 100%;
text-align: center;
}