gpt4 book ai didi

css - 内联 CSS 不会被外部 CSS 中的 !important 覆盖

转载 作者:行者123 更新时间:2023-11-28 07:31:59 25 4
gpt4 key购买 nike

我正在尝试制作 this site react 灵敏。

我已将以下 CSS 添加到 Wordpress 主题的 custom.css 中:

li#vfb-3 {
color: #808080;
}

p#form_success, .vfb-form-success {
color: #CCFFCC;
}

#menu {
background-image: none;
background: #ffffff;
/* Old browsers */
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2ZmZmZmZiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNlNmU2ZTYiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(top,#ffffff 0%,#e6e6e6 100%);
/* FF3.6+ */
background: -webkit-gradient(linear,left top,left bottom,color-stop(0%,#ffffff),color-stop(100%,#e6e6e6));
/* Chrome,Safari4+ */
background: -webkit-linear-gradient(top,#ffffff 0%,#e6e6e6 100%);
/* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top,#ffffff 0%,#e6e6e6 100%);
/* Opera 11.10+ */
background: -ms-linear-gradient(top,#ffffff 0%,#e6e6e6 100%);
/* IE10+ */
background: linear-gradient(to bottom,#ffffff 0%,#e6e6e6 100%);
/* W3C */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff',endColorstr='#e6e6e6',GradientType=0);
/* IE6-8 */
}

@media (max-width:959px) {
.container, #menu, #featured, #slides, .slide .overlay, .slide .overlay2 {
width: 100% !important;
}

#featured {
height: auto !important;
}

#header {
height: 168px;
}

img {
max-width: 100% !important;
height: auto;
}

#menu {
height: auto;
}
}

@media (max-width:461px) {
.container, #menu, #featured, #slides, .slide .overlay, .slide .overlay2 {
width: 100%;
}

#featured {
height: auto !important;
}

#header {
height: 202px;
}

img {
max-width: 100% !important;
height: auto;
}

#menu {
height: auto;
}
}

@media (max-width:337px) {
.container, #menu, #featured, #slides, .slide .overlay, .slide .overlay2 {
width: 100%;
}

#featured {
height: auto !important;
}

#header {
height: 236px;
}

img {
max-width: 100% !important;
height: auto;
}

#menu {
height: auto;
}
}

图像 slider 包含一个 #slides 元素,它由以下内容生成:

<div id="slides" style="background-image: none; width: 960px; height: 447px;">

但是,当我将浏览器宽度减小到小于 960 像素时,我的 #slides {width: 100% !important;} CSS 没有被应用。

为什么会这样?谢谢。

最佳答案

你的结构有点像下面的代码-

<div id="slides"></div>
<div class="slide" style="width:960px;...*other styles*">
*tags within*
</div>
<div class="slide" style="width:960px;...*other styles*">
*tags within*
</div>
<div class="slide" style="width:960px;...*other styles*">
*tags within*
</div>
<div class="slide" style="width:960px;...*other styles*">
*tags within*
</div>
</div>

现在即使 #slides 在屏幕尺寸小于 960px 时将宽度设为 100%,它的子级 .slide 也会占用 960px 图像标签也是如此在.slides 中。您还必须将 .slidesimg 覆盖为 width: 100% as -

@media (max-width:959px) {
#slides > .slide, #slides img {
width: 100% !important;
}
}

关于css - 内联 CSS 不会被外部 CSS 中的 !important 覆盖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31455765/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com