小编Pad*_*ash的帖子

覆盖子元素上的文本装饰

我想覆盖子元素中的父 css。我想在父元素下划线,而不是在子元素下划线。

.parent {
  text-decoration: underline;
  color: red;
}
.child {
  color: green;
  text-decoration: none !important;
}
.sub-child {
  color: green;
  text-decoration: none !important;
}
Run Code Online (Sandbox Code Playgroud)
<div class="parent">Inside parent
  <div class="child">Inside first child
    <div class="sub-child">Inside 1st child of 1st child
    </div>
  </div>
  <div class="child">Inside 2nd child
    <div class="sub-child">Inside 1st child of 2nd child</div>
    <div class="sub-child">Inside 2nd child of 2nd child</div>
  </div>
  <div class="child">
    Inside 3rd child
    <div class="sub-child">Insde 1st child of 3rd child</div>
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

html css

5
推荐指数
2
解决办法
1989
查看次数

标签 统计

css ×1

html ×1