如何禁用CSS样式?

问题描述

我目前正在我的React App中使用antd软件包,包括CSS软件包。但是,我想禁用一条规则:

body,html {
        width: 100%;
        height: 100%;
}

如何在不导入CSS的情况下禁用/删除此规则?

解决方法

您可以覆盖在CSS包之后导入个人CSS的规则

,

如果由于某种原因无法访问该CSS,则可以添加自己的CSS;

body,html {
    width: inherit;
    height: inherit;
}

示例:

body {
    background-color: blue;
}

body {
    background-color: inherit;
}
<div>
  The body background colour should be BLUE as per CSS,but because of the following INHERIT attribute,it is now back to default white.
</div>

您可以在此处详细了解inherit属性;

https://www.w3schools.com/cssref/css_inherit.asp

https://developer.mozilla.org/en-US/docs/Web/CSS/inherit

,

将规则覆盖到您的styles.css(或您正在全局使用的任何样式文件)中

body,html {
    width: initial !important;
    height: initial !important;
}
,

您尝试过吗?

body,html {
      //  width: 100%;
      //  height: 100%;
}