css - 如何将具有功能的高级CSS应用于除一个元素以外的主体

标签 css html

我正在使用 HTML5 模板,但我遇到了这个 CSS 属性,它具有一些功能,例如 is-loadingis-switching:

body.is-loading *, body.is-loading *:before, body.is-loading *:after, body.is-switching *, body.is-switching *:before, body.is-switching *:after {
            -ms-animation: none !important;
            animation: none !important;
            transition: none !important;
            transition-delay: none !important;
        }

我不能删除它,因为我的模板不起作用,基本上,它会在开始时(加载时)禁用动画和过渡,但因为我有一个 loading div id loading因此它不会工作,因为所有 body 的动画都已被禁用。

根据我在互联网上找到的信息,我尝试使用 not() 将 CSS 应用于除我的 Id loading 之外的所有内容,如下所示,但不幸的是它没有'工作:

body.is-loading *:not(#loading), body.is-loading *:not(#loading):before, body.is-loading *:not(#loading):after, body.is-switching *:not(#loading), body.is-switching *:not(#loading):before, body.is-switching *:not(#loading):after {
        -ms-animation: none !important;
        animation: none !important;
        transition: none !important;
        transition-delay: none !important;
    }

最佳答案

如果您不能修改 body 标签但可以添加新的 css,则可以通过在 body css 标签下方添加代码来提高特异性。

body.is-loading *,
body.is-loading *:before,
body.is-loading *:after,
body.is-switching *,
body.is-switching *:before,
body.is-switching *:after {
  -ms-animation: none !important;
  animation: none !important;
  transition: none !important;
  transition-delay: none !important;
}

#loading {
  -ms-animation: all ease-in-out 0.3s !important;
  animation: all ease-in-out 0.3s !important;
  transition: all ease-in-out 0.3s !important;
  transition-delay: all ease-in-out 0.3s !important;
}

关于css - 如何将具有功能的高级CSS应用于除一个元素以外的主体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46422902/

相关文章:

css - 有没有办法将鼠标悬停在一个元素上并影响另一个元素?

html - 使用 HTML 中的类居中彩色字母文本

html - 在CSS中覆盖div样式链接颜色

php - 如何使用 HTML-CSS 将一个图像叠加在另一个具有透明效果的图像上

jQuery - 动画溢出?

html - 使用 MarkerClusterer 的标记上的信息窗口

CSS:避免使用列表元素符号和 float 折叠边距

javascript - 保留表单提交后显示的div

javascript - 将 Markdown 文件加载到 HTML 文本区域

javascript - Bootstrap 模式正常出现但没有正确显示其中的内容?