【发布时间】:2021-01-31 01:28:03
【问题描述】:
在下面的 sn-p 中,我想覆盖内联样式,所以 h1,h2,h3,h4 标签具有写在 CSS 文件中的样式。
- 我不能/不允许删除内联样式(它由名为 Froala 的 HTML 编辑器生成)
- 我们不知道应用于哪个元素的内联样式,它可能是
h标记本身或span或任何其他子/嵌套元素。 - 我们不知道存在多少嵌套元素。
- 为方便起见,我们可以假设内联样式始终应用于
span,但span可以是第n 个孩子
.wrapper{}
h1,h2,h3,h4 {line-height:1.5 !important;}
h1,h2 > span {color:rgb(41,105,176) !important;}
h3,h4 > span {color:rgb(184, 49, 47) !important;}
<div class="wrapper">
<h1>Dyspepsi</h1>
<h2><span style="color: rgb(0,0,0);">Dyspepsi</span></h2>
<h1><strong><em><span style="color: rgb(0,0,0); line-height:2.5">Dyspepsi</span></em></strong></h1>
<h2><strong><em><span style="color: rgb(0,0,0);">Dyspepsi</span></em></strong></h2>
<h3><strong><span style="color: rgb(0,0,0); border-bottom: 1px solid;">Dyspepsi</span></strong></h3>
<h4><strong><em><span style="color: rgb(0,0,0);">Dyspepsi</span></em></strong></h4>
</div>
【问题讨论】:
标签: html css css-selectors inline-styles