【问题标题】:Override CSS list-style-type for h3 elements覆盖 h3 元素的 CSS list-style-type
【发布时间】:2017-09-24 06:06:49
【问题描述】:

我正在开发一个使用 Middleman 构建的博客网站。列表的默认列表样式类型位于 _lists.scss 中,并且在每个 li 元素都有一个光盘的情况下可以正常工作。但是,我想为 li 中的 h3 元素覆盖它。

这是我的列表 html 的示例:

<div id="main" role="main">
<ul>
    <li>
      <h3>heading</h3>
    </li>
</ul>

这是我一直在使用的 css:

ul, ol {
  margin: 0;
  padding: 0;
  list-style-type: none;

  &%default-ul {
    list-style-type: disc;
    margin-bottom: $base-line-height / 2;
    padding-left: $base-line-height;
  }

  &%default-ol {
    list-style-type: decimal;
    margin-bottom: $base-line-height / 2;
    padding-left: $base-line-height;
  }
}

#main > ul > li > h3 {
    list-style-type: none;
}

但屏幕上没有任何变化。

我缺少什么吗?任何帮助表示赞赏。

【问题讨论】:

标签: css middleman


【解决方案1】:

将 list-style-type 赋予任何 ul 的 li,而不是赋予 li 的子级 试试这样

#main > ul > li{
    list-style-type: none;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-08-18
    • 1970-01-01
    • 1970-01-01
    • 2011-09-29
    • 2016-02-06
    • 2013-06-09
    • 2018-08-24
    相关资源
    最近更新 更多