【问题标题】:Firefox and Safari MarginsFirefox 和 Safari 边距
【发布时间】:2011-11-24 11:11:08
【问题描述】:

如何让我的边距和填充在 firefox 和 safari 中正确显示?一般而言,正确的 hack 是什么?

【问题讨论】:

    标签: css firefox safari margins


    【解决方案1】:

    您应该使用 CSS 重置,这会将所有元素重置为默认值,因此将在所有浏览器中显示相同的值,包括 Internet Explorer。

    更多信息在这里:http://meyerweb.com/eric/tools/css/reset/

    【讨论】:

      【解决方案2】:

      这就是我的做法,它删除并消除了 HTML 元素的不一致默认样式。首先我使用yui reset重置样式表:

      /* RESET
      ---------------------------
      Yahoo Reset
      version: 3.3.0
      build: 3167
      */
      html{color:#000;background:#FFF;}body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}li{list-style:none;}caption,th{text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}q:before,q:after{content:'';}abbr,acronym{border:0;font-variant:normal;}sup{vertical-align:text-top;}sub{vertical-align:text-bottom;}input,textarea,select{font-family:inherit;font-size:inherit;font-weight:inherit;}input,textarea,select{*font-size:100%;}legend{color:#000;}
      

      然后我使用yahoo css base 来声明常见 HTML 元素的样式:

      /* BASE 
      --------------------------------------
      Yahoo Base
      version: 3.3.0
      build: 3167
      */
      
      h1,h2,h3{margin:1em 0;}h1,h2,h3,h4,h5,h6,strong{font-weight:bold; color:#333}abbr,acronym{border-bottom:1px dotted #000;cursor:help;}em{font-style:italic;}blockquote,ol,dl{margin:1em;}ol,dl{margin-left:2em;}ol li{list-style:decimal outside;}dl dd{margin-left:1em;}th{font-weight:bold;text-align:center;}caption{margin-bottom:.5em;text-align:center;}fieldset,table,pre{margin-bottom:1em;}
      

      【讨论】:

      • 我已经重置了我的 css,但我的 1 个元素在 Firefox 中仍然关闭。我现在需要专门针对一条规则执行此操作……一组用于 safari,另一组用于 Firefox。我如何为这两种浏览器做一个margin hack?
      猜你喜欢
      • 2011-08-30
      • 2016-07-01
      • 2017-10-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-25
      • 2014-06-22
      相关资源
      最近更新 更多