gpt4 book ai didi

css - 有没有办法在 css 中自动缩进嵌套部分?

转载 作者:太空宇宙 更新时间:2023-11-03 21:09:25 24 4
gpt4 key购买 nike

我有这个代码:

<section>
<h1>Test</h1>
<p>Text</p>
<section>
<h1>Test2</h1>
<p>Text2</p>
</section>
</section>

我希望它看起来有类似的缩进:

<h1>Test</h1>
<p>Text</p>
<h2 style="margin-left: 40px">Test2</h2>
<p style="margin-left: 40px">Text2</p>

最佳答案

您可以只在 section 元素上使用 margin-left,但不能在第一个元素上使用。

section:not(.first) {
margin-left: 40px;
}
<section class="first">
<h1>Test</h1>
<p>Text</p>
<section>
<h1>Test2</h1>
<p>Text2</p>
<section>
<h1>Test3</h1>
<p>Text3</p>
</section>
</section>
</section>

关于css - 有没有办法在 css 中自动缩进嵌套部分?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48580089/

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