简体   繁体   English

我如何将 html “ul” 元素置于 bootstrap 4(水平 + 垂直)内部<section><div class="row"><div class="col-sm"></div><div id="text_translate"><p>如何将 html“ <strong>ul</strong> ”元素在 bootstrap4(水平 + 垂直)中居中,水平对齐“ <strong>li</strong> ” </p><p></p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"><div class="snippet-code"><pre class="snippet-code-html lang-html prettyprint-override"> &lt;section&gt; &lt;div class='row'&gt; &lt;div class='col-sm'&gt; &lt;ul&gt; &lt;li&gt;A&lt;/li&gt; &lt;li&gt;B&lt;/li&gt; &lt;li&gt;C&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; &lt;/section&gt;</pre></div></div><p></p></div></div></section>

[英]How I center html “ul” element in bootstrap 4 (horizontal + vertical) inside <section><div class='row'><div class='col-sm'>

How to center html " ul " element in bootstrap4 (horizontal + vertical) with horizontal aligned " li "如何将 html“ ul ”元素在 bootstrap4(水平 + 垂直)中居中,水平对齐“ li

 <section> <div class='row'> <div class='col-sm'> <ul> <li>A</li> <li>B</li> <li>C</li> </ul> </div> </div> </section>

If you use this code the list will be displayed in the center of the yellow box.如果您使用此代码,列表将显示在黄色框的中心。 I don't know why it won't work on the code preview on stackoverflow, but here you can see that it works.我不知道为什么它在 stackoverflow 上的代码预览中不起作用,但在这里您可以看到它起作用。

 <section> <div class='row'> <div class='col-sm' style="background-color: yellow; display:grid;height: 100%"> <ul style="margin: center;"> <li>A</li> <li>B</li> <li>C</li> </ul> </div> </div> </section>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM