gpt4 book ai didi

css - 在 div 中居中对齐 div?

转载 作者:行者123 更新时间:2023-12-03 22:52:38 25 4
gpt4 key购买 nike

如何将 3 个 float div 居中对齐,以页面为中心?

<div style="width:100%">
<div style="width:90%">
<div style="width:80%">
//Content
</div>
</div>
</div>

最佳答案

使用 margin: auto在 CSS 中。

<div style="background-color: red; height: 100px; width: 500px; margin: auto;">
<div style="background-color: green; height: 100px; width: 300px; margin: auto;">
<div style="background-color: blue; height: 100px; width: 100px; margin: auto;">
//Content
</div>
</div>
</div>

关于css - 在 div 中居中对齐 div?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8587942/

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