可以使用flexbox来解决这个问题。在父元素中使用display: flex和justify-content: center属性,即可轻松实现内容水平居中。然后给子元素设置flex属性,确保它们在主轴上剩余空间平均分配。以下是一个示例代码:
HTML代码:
CSS代码:
.wrapper { display: flex; flex-direction: column; justify-content: center; align-items: center; }
h1 { margin-bottom: 20px; }
ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; align-items: center; }
li { flex: 1; text-align: center; }
上一篇:标题生成的GPT2模型
下一篇:标题视图的模型