gpt4 book ai didi

html - 如何在 Bootstrap 模式中居中对齐左对齐列表

转载 作者:搜寻专家 更新时间:2023-10-31 21:50:03 24 4
gpt4 key购买 nike

我是一个 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">&times;</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

最佳答案

您可以给 a 设置 100% 的宽度,然后将文本居中对齐。

这将是响应式的,因此您无需担心添加特定宽度。

尝试添加这两行 CSS

.modal-list > li > a {
color:#333;
text-decoration: none;
list-style: none;
display: block;
text-align: left;

width: 100%;
text-align: center;
}

关于html - 如何在 Bootstrap 模式中居中对齐左对齐列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22594106/

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