【问题标题】:Customizing a webpage's css in Mozilla Firefox在 Mozilla Firefox 中自定义网页的 CSS
【发布时间】:2012-12-15 17:40:30
【问题描述】:

我想自定义网站的 CSS 并保存以供 Mozilla 加载。这样当 Mozilla 从该 url 加载 html 时,它会使用我的 css 文件而不是外部文件。 我不知道如何让 Mozilla 做到这一点,当我向 url 发出新请求时,加载了站点的 css 而不是我的。 我该如何设置?

【问题讨论】:

    标签: css firefox web customization


    【解决方案1】:

    对于我们大多数人来说,最直接的方法是使用名为 Stylish 的 Mozilla Firefox 插件。它允许您为特定页面或域编写、保存和使用自己的样式表,覆盖(如有必要)作者自己的规则的一部分。

    在引擎盖下它只不过是内置的 Firefox 工具 - 你有 userContent.css 文件,它使用 CSS 自己支持的 @document 语法和 !important 在规则之后完成你的任务之后。

    这实际上是 CSS 的核心。它或多或少被设计成允许用户覆盖作者样式表,而 Firefox 让这件事变得有些容易。

    您可以获得更广泛的解释here

    【讨论】:

      【解决方案2】:

      为此

      您可以扫描用户代理并找出哪个浏览器及其版本。包括操作系统特定样式的操作系统 您可以针对特定浏览器使用各种 CSS Hacks 或脚本或插件来识别浏览器并将各种类应用于元素

      使用 jQuery

      ​​>

      您所追求的是浏览器检测:

      if ($.browser.mozilla) { ... 
      

      但是,不鼓励浏览器嗅探,因为它很容易欺骗用户代理,即伪装成另一个浏览器!

      您最好以自己的方式或通过 jQuery.support 接口使用特征检测:http://api.jquery.com/jQuery.support/

      这是一篇关于扩展它以供您自己使用的文章:http://www.waytoocrowded.com/2009/03/14/jquery-supportminheight/

      使用 PHP

      http://php.net/manual/en/function.get-browser.php
      http://techpatterns.com/downloads/php-browser-detection-basic.php
      http://techpatterns.com/downloads/php_browser_detection.php (contains JS also)
      

      然后根据检测到的浏览器创建动态 CSS 文件 这是一个 CSS Hacks 列表

      选择器技巧

      /* IE6 and below */
      * html #uno  { color: red }
      
      /* IE7 */
      *:first-child+html #dos { color: red } 
      
      /* IE7, FF, Saf, Opera  */
      html>body #tres { color: red }
      
      /* IE8, FF, Saf, Opera (Everything but IE 6,7) */
      html>/**/body #cuatro { color: red }
      
      /* Opera 9.27 and below, safari 2 */
      html:first-child #cinco { color: red }
      
      /* Safari 2-3 */
      html[xmlns*=""] body:last-child #seis { color: red }
      
      /* safari 3+, chrome 1+, opera9+, ff 3.5+ */
      body:nth-of-type(1) #siete { color: red }
      
      /* safari 3+, chrome 1+, opera9+, ff 3.5+ */
      body:first-of-type #ocho {  color: red }
      
      /* saf3+, chrome1+ */
      @media screen and (-webkit-min-device-pixel-ratio:0) {
       #diez  { color: red  }
      }
      
      /* iPhone / mobile webkit */
      @media screen and (max-device-width: 480px) {
       #veintiseis { color: red  }
      }
      
      
      /* Safari 2 - 3.1 */
      html[xmlns*=""]:root #trece  { color: red  }
      
      /* Safari 2 - 3.1, Opera 9.25 */
      *|html[xmlns*=""] #catorce { color: red  }
      
      /* Everything but IE6-8 */
      :root *> #quince { color: red  }
      
      /* IE7 */
      *+html #dieciocho {  color: red }
      
      /* Firefox only. 1+ */
      #veinticuatro,  x:-moz-any-link  { color: red }
      
      /* Firefox 3.0+ */
      #veinticinco,  x:-moz-any-link, x:default  { color: red  }
      
      
      
      /***** Attribute Hacks ******/
      
      /* IE6 */
      #once { _color: blue }
      
      /* IE6, IE7 */
      #doce { *color: blue; /* or #color: blue */ }
      
      /* Everything but IE6 */
      #diecisiete { color/**/: blue }
      
      /* IE6, IE7, IE8 */
      #diecinueve { color: blue\9; }
      
      /* IE7, IE8 */
      #veinte { color/*\**/: blue\9; }
      
      /* IE6, IE7 -- acts as an !important */
      #veintesiete { color: blue !ie; } /* string after ! can be anything */
      

      来源:http://paulirish.com/2009/browser-specific-css-hacks/

      如果你想使用插件,那么这里是一个

      http://rafael.adm.br/css_browser_selector/

      【讨论】:

        【解决方案3】:

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2012-09-20
          • 2014-10-18
          • 1970-01-01
          • 2014-05-19
          • 1970-01-01
          • 2011-09-04
          相关资源
          最近更新 更多