【问题标题】:trying to alter a sites color with Stylish but some elements refuse to change尝试使用 Stylish 更改网站颜色,但某些元素拒绝更改
【发布时间】:2016-07-23 08:33:02
【问题描述】:

不会改变的元素在这个页面中(http://www.animefansftw.org/community/threads/fate-kaleid-liner-prisma%E2%98%86illya-3rei.641/add-reply) 好像没有生效的代码是

 body[style="overflow-y: hidden; min-height: 259px; background: black none repeat scroll 0% 0%;"]
 {
   background: blue !important;

 }

我真正的问题是为什么它不起作用以及如何使它起作用

我的风格(FF v47.0.1) @namespace url(http://www.w3.org/1999/xhtml);

@-moz-document domain("animefansftw.org")
{
  a:link{color: #b7e2fb !important;}
  a:visited{color: #1eadff !important;}
  a:hover{color: green !important;}
  a:active{color: red !important;}


 *, body, #content-wrapper, #footer-widgets,
 single-post,.discussionList .discussionListItem.sticky .posterAvatar,
 .discussionList .discussionListItem.sticky .stats,
 .discussionList.discussionListItem.moderated .listBlock,
 .discussionListItem.InlineModChecked .posterAvatar,
 .discussionListItem.InlineModChecked .main,
 .discussionListItem.InlineModChecked .stats,
 .discussionListItem.InlineModChecked .lastPost,
 .discussionListItem.moderated.InlineModChecked,
 .discussionListItem.deleted .posterAvatar
 {
   background: black;
   color: white !important;
 }

 .footer-widgets-border-left, #DiscussionListOptionsHandle a
 {
   background: #00004d;
 }

 .footer-widgets-border-right
 {
   background: #000080;
 }

 img[alt="default"]
 {
   -webkit-filter: invert(100%);
   filter: invert(100%);
 }

 .cat-list li.ep-title:hover
 {
   background: gray !important;
   border-left: 5px solid #f5f211;
   border-right: 5px solid #1143f2;
 }

 li.ep-title
 {
   margin: 0 !important;
   background: black !important;
   border-bottom: 3px solid #00004d;
   border-left: 0px solid transparent !important;
   border-right: 0px solid transparent !important;
 }

 .dl-box
 {
   background: black;
   border: 1px solid black;
   box-shadow: -10px -10px 5px 0px #00004d;
 }

 .dl-title
 {
   background: -moz-linear-gradient(45deg, #00004d, blue, blue, #00004d);
 }

 .post-date .date, #social-wrapper, #nav, h3.newanimetitle,
 #footer-bottom, .hasFlexbox .nodeList .categoryStrip,
 .hasFlexbox .sidebar .visitorPanel .secondaryContent,
 .sidebar .section .secondaryContent,
 .threadListSeparator,.discussionList .sectionFooter
 {
   background: -moz-linear-gradient(top, #00004d, #000080, #000080, #00004d) no-repeat !important;
 }

 .dl-item
 {
   background: #1a1a1a;
 }

 #header-bottom
 {
   float: left;
   background: url("http://puu.sh/2b5au.jpeg") #000000 !important;
   width: 980px;
   height: 165px;
 }

 #respond textarea
 {
   font-family: "Times New Roman", Times, serif;
   font-size: large !important;
   background: #00001a !important;
   border: 1px solid #00004d !important;
 }

 .nodeList .node.level_1
 {
   background: #00001a !important;
   box-shadow: 1px 2px 3px #00001a;
 }

 .nodeList .categoryStrip
 {
   border-top: 2px solid blue;
 }

 .hasFlexbox .node.level_2 .nodeInfo, .visitorPanel .stats dl,
 .blendedEditor .redactor_box .redactor_toolbar
 {
   background: 0;
 }

 .hasFlexbox .message .messageUserInfo
 {
   background: #00001a !important;
 }

 div[style="background: #eeeeee; width: 620px; margin: 0 auto; padding:15px; font: 10pt italic; border: 1px solid #333333;"],
 .message .dark_postrating.likesSummary, .dark_postrating
 {
   background: rgb(0, 0, 26) none repeat scroll 0% 0% !important;
 }

 .quickReply,.mainContainer .mainContent, .mainContainer_noSidebar
 {
   background: #00001a;
   border-top: 2px solid #000080;
 }

 .blendedEditor .redactor_box .redactor_toolbar, .messageList .message
 {
   border-top: 2px solid #000080;
 }

 body[style="overflow-y: hidden; min-height: 99px;"],
 .submitUnit .button, .redactor_toolbar
 {
   background: rgb(0, 0, 26) none repeat scroll 0% 0% !important;
 }

 element, body[style="overflow-y: hidden; min-height: 259px; background: black none repeat scroll 0% 0%;"]
 {
   background: blue !important;

 }

}

【问题讨论】:

    标签: css stylish


    【解决方案1】:

    记住 css 层次结构的基本规则的含义和重要性:

    1. 内联 - 最高重要性

    2. 内部

    3. 外部

    根据我对 css 的理解,无论我能从你的代码中得到什么,你首先暗示了一个 css 属性作为父元素的 !important ,然后可能在子元素上使用了一些东西。

    但请记住,即使在暗示 !important 时它也不会显示其影响,因为它在该父属性下。所以,你需要为它编写内联 css,虽然不推荐。

    例如:如果 font-size 设置为 15px!important 对 parent 本身,则使用内联 css 来更改 child 的 font-size。

    我遵循的最佳规则是永远不要暗示 !important 属性,直到它是最后可能的解决方案。如果您担心它会被其他一些代码干扰,您可以为您的类和 id 使用更好且唯一的名称。

    【讨论】:

    • 你说某些东西优先,就像在源代码中有些东西告诉盒子是白色的!重要的,让我们说它是这样(现在看不到),我该怎么做才能覆盖它?甚至尝试了一个特定的选择器!重要但它仍然没有这样做
    • 正如我所说,尝试直接在 html 元素中暗示内联 css。例如:
      如果它反映了变化,那么很可能某个父元素现在正在显示它的属性,
    • 也许我没听懂,你是在叫我修改 html 代码吗?不是我的网站,我只是在写一个“时尚”的风格,主要是为了我自己(也许会分享“时尚”网站。
    • 是的,我告诉你修改 HTML 代码。好的,如果这是不可能的,请尝试找到您赋予父元素的任何重要属性。在您的情况下,它的“背景”属性。我得到的是,您已将重要属性应用于父级,然后再次将重要属性赋予子级。这不适用于外部/内部级别的 css
    猜你喜欢
    相关资源
    最近更新 更多
    热门标签