如何将Divi(HTML/CSS)嵌套列表中项目之间的间距标准化?
我是HTML的新手,这可能很容易解决。我正在使用Divi更新WordPress站点,并正在创建一些带有子点的项目符号点的嵌套无序列表< ul>
。
每个子点都需要一个嵌入式子列表,默认格式似乎意味着越多的子点,在父点之后的空间越多。
我屏幕截图并将其标记为显示间距的多样性:
子名单。
我认为,代码看起来很正常:
.bullet_list_spacing ul>li {
margin-bottom: 16px;
}
.bullet_list_spacing ul>li:last-child {
margin-bottom: 0 !important;
}
.bullet_list_spacing ul>li:first-child {
margin-top: 0 !important;
}
.bullet_list_spacing ul {
margin-top: 0 !important;
margin-bottom: 0 !important;
padding-top: 0 !important;
padding-bottom: 0 !important;
}
<div class="bullet_list_spacing">
<ul>
<li>text</li>
<li>text
<ul>
<li>text</li>
<li>text</li>
<li>text</li>
</ul>
</li>
<li>text
<ul>
<li>text</li>
<li>text</li>
</ul>
</li>
</ul>
</div>
我尝试通过创建和格式化CSS类(使用此处和 /a>),然后抛出我能想到的所有变体。
我将CSS放在Divi的“外观”菜单的“自定义CSS”部分中( screenshot )并在文本模块设置的“高级”部分中应用CSS类( screenShot。 )。
I'm very new to HTML and this may be an easy fix. I'm updating a Wordpress site using Divi and am creating some nested unordered lists <ul>
for bullet points with subpoints.
Every subpoint requires an embedded sub-list, and the default formatting seems to mean that the more sub-points, the more space after the parent point.
I screenshot and labeled it to show the variety of spacing:
I just want the spacing between every list item to be the same, regardless of whether the item has an embedded sub-list.
The code looks pretty normal, I think:
.bullet_list_spacing ul>li {
margin-bottom: 16px;
}
.bullet_list_spacing ul>li:last-child {
margin-bottom: 0 !important;
}
.bullet_list_spacing ul>li:first-child {
margin-top: 0 !important;
}
.bullet_list_spacing ul {
margin-top: 0 !important;
margin-bottom: 0 !important;
padding-top: 0 !important;
padding-bottom: 0 !important;
}
<div class="bullet_list_spacing">
<ul>
<li>text</li>
<li>text
<ul>
<li>text</li>
<li>text</li>
<li>text</li>
</ul>
</li>
<li>text
<ul>
<li>text</li>
<li>text</li>
</ul>
</li>
</ul>
</div>
And I tried to remedy the issue by creating and formatting a CSS class (using code from here and here) and then just throwing every variation I could think of at it.
I put the CSS in the "custom CSS" section of Divi's "Appearance" menu (screenshot here) and applied the CSS class in the "advanced" section of the text module's settings (screenshot here).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
主要问题是
&gt;
选择直接的孩子。只需将保证金顶/底部应用:0;
上所有li
。然后,您通过使用ul&gt; li&gt; ul&gt; li
将Margin-Bottom:16px
应用于所有第二级LI。要使用last-Child
您不希望使用此应用的例外,您可以起诉:not()
selector:selector:The main issue is the
>
which onyl selects direct childs. Just apply themargin-top/bottom: 0;
to allli
. Then you applymargin-bottom: 16px
to all 2nd level li by usingul>li>ul>li
. To use the exception of thelast-child
where you dont want this to applied, you can sue the:not()
selector: