简体   繁体   English

为什么 li 标记未在 div 元素内的 ul/ol li 中对齐中心?

[英]why li marker is not aligning center in ul/ol li inside div element?

why li marker is not aligning center in ul/ol li inside div element?为什么 li 标记未在 div 元素内的 ul/ol li 中对齐中心?

 div{ text-align: center; }
 <div> <ul> <li>hello world</li> </ul> </div>

check the width of your ul , li .检查你的ulli的宽度。 Better use display: flex for your div, set justify-content: center or align-items: center;更好地使用display: flex为你的 div,设置justify-content: centeralign-items: center;

You can make the markers inside the li space by adding list-style-position: inside to your ul .您可以通过将list-style-position: inside添加到ul中来在li空间内制作标记。

 div{ text-align: center; } ul{ list-style-position: inside; }
 <div> <ul> <li>hello world</li> </ul> </div>

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

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