如何将Divi(HTML/CSS)嵌套列表中项目之间的间距标准化?

发布于 2025-02-11 00:26:12 字数 1892 浏览 2 评论 0原文

我是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 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

‘画卷フ 2025-02-18 00:26:12

主要问题是&gt;选择直接的孩子。只需将保证金顶/底部应用:0;上所有li。然后,您通过使用ul&gt; li&gt; ul&gt; liMargin-Bottom:16px应用于所有第二级LI。要使用last-Child您不希望使用此应用的例外,您可以起诉:not() selector:selector:

.bullet_list_spacing li {
  margin-top: 0;
  margin-bottom: 0;
}

.bullet_list_spacing ul>li>ul>li:not(:last-child) {
  margin-bottom: 16px;
}
<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>

The main issue is the > which onyl selects direct childs. Just apply the margin-top/bottom: 0; to all li. Then you apply margin-bottom: 16px to all 2nd level li by using ul>li>ul>li. To use the exception of the last-child where you dont want this to applied, you can sue the :not() selector:

.bullet_list_spacing li {
  margin-top: 0;
  margin-bottom: 0;
}

.bullet_list_spacing ul>li>ul>li:not(:last-child) {
  margin-bottom: 16px;
}
<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>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文