gpt4 book ai didi

css - 将列表项与标题对齐

转载 作者:行者123 更新时间:2023-11-28 16:36:07 24 4
gpt4 key购买 nike

我正在尝试将无序列表与我的网站标题完美居中,标题在顶部,UL 元素在下方居中。

问题是它确实居中,但与头顶标题不完全对齐。它稍微偏右。

这是我的代码:

.title{
text-align: center;

}

nav{
display: block;
margin-left: auto;
margin-right: auto;
width: 50%;
background: blue;
}

li {
text-align: center;
display: inline-block;
list-style-type: none;
margin: 0;
padding: 0;
background: red;
}

最佳答案

ul {
padding: 0;
}

轻微的右侧偏差是因为整个列表的默认填充,而不是单个列表项。将其设置为零可消除不必要的偏移量。

关于css - 将列表项与标题对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34499763/

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