如何在打印 CSS 中覆盖内联样式

how to overwrite inline styles in print css?

本文关键字:覆盖 样式 CSS 打印      更新时间:2023-09-26

我知道,内联样式是"邪恶的",但是在html中插入了javascript(jQuery动画)。 那么,这可能吗?

这个:

  <div style="background: red;">
        The inline styles for this div should make it red.
    </div>

可以覆盖:

div[style] {
   background: yellow !important;
}

您可以将!important添加到任何 css 属性

尝试在打印样式表中的值和分号之间加上 !important:

body {
    background-color: #0f0 !important;
}