• CHROME对CSS的解析


    最近完成的一个项目需要做对Chrome的支持,在这个过程中发现了一个Chrome对于Css解析与FF、IE等的区别,在这里总结一下。

    项目的需求是需要在屏幕的中央显示一个提示框,这个对于FF和IE都已经很成熟了,利用负边距能够很容易的实现:

    首先看一下页面:

    Code

    加入css

    <style type='text/css'>
        html 
    { height:100%; }
        body 
    { margin:0px; padding:0px; position:relative; height:100%; }
        #wrapper 
    { width:100%; height:100%; position:relative;; left:0px; top:0px; }
        #contentbox 
    { width:400px; height:400px; border:2px solid green; position:relative; top:50%; left:50%; 
            margin-left
    :-200px; margin-top:-200px; }
    </style>

    这样,在FF3、IE6/7中都能,很好的实现水平和垂直居中,而在chrome中,出现了问题。

     

    最后,发现是chrome对于position的解析和其他浏览器不同,加入css hack for chrome后,一切正常。

     body:nth-of-type(1) #contentbox { position:absolute;}

  • 相关阅读:
    四川省选2012 day1 喵星球上的点名 (后缀数组,并不是完全的正解)
    6.2.1 最短路
    5.3.3 敌兵布阵
    6.1.1 Constructing Roads
    6.2.4 Arbitrage
    6.1.6 Jungle Roads
    5.3.6 Cow Sorting (HDU 及 POJ)
    6.2.5 Trucking
    6.1.4 还是畅通工程
    6.1.3 畅通工程
  • 原文地址:https://www.cnblogs.com/cocowool/p/1411342.html
Copyright © 2020-2023  润新知