gpt4 book ai didi

html - 在容器中居中 ul

转载 作者:太空宇宙 更新时间:2023-11-04 00:05:53 25 4
gpt4 key购买 nike

我很难将 3 个 li 元素置于容器宽度的中心。我正在处理响应式布局,所以我不想在任何元素上使用固定宽度。这是我的代码的 fiddle http://jsfiddle.net/vzNbr/

请注意,如果您扩展与容器左侧对齐而不是居中的输出屏幕。 CSS 很简单:

.container {
width: 70%;
margin: 0 auto;
}

#about {
background-color: #ebebeb;
height: 100%;
width: 100%;
}

#about ul.info {
display: block;
width: 100%;
margin: 0 auto;
list-style: none;
padding: 0;
}

#about ul.info li {
width: 20%;
float: left;
display: inline-block;
vertical-align: top;
margin: 1.5em;
font-size: .8em;
}

屏幕截图:enter image description here

最佳答案

你需要取出float:left,将你的ul设置在display:tableli作为 display:table-cell。这是您的演示:http://jsfiddle.net/vzNbr/1/

关于html - 在容器中居中 ul,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14898664/

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