V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
Eysa
V2EX  ›  问与答

当 html 遇到 css 后, 小h会有什么样的化学反应呢/?

  •  
  •   Eysa · 2012-02-24 21:19:45 +08:00 · 3847 次点击
    这是一个创建于 4450 天前的主题,其中的信息可能已经有所发展或是发生改变。
    <body>
    <div class="page" style="background-color: Teal; width: 100%; height: 100%; position: fixed;">
    <div id="nav-home" style="background-color: White; width: 30%; height: 100px; margin-top: 40%;
    margin-left: 35%; z-index: 1000; position: absolute;">
    </div>
    </div>
    </body>



    求解, 确切的说, 应该是 IE 这个老大难 ..

    为神马 IE 下就离的那么远,. 那么远.....
    6 条回复    1970-01-01 08:00:00 +08:00
    Eysa
        1
    Eysa  
    OP
       2012-02-24 21:39:44 +08:00
    nav-home 的位置不对啊... 这里牛人应该很多的哦.
    SolidZORO
        2
    SolidZORO  
       2012-02-24 21:43:27 +08:00
    css hack 很难说的,你得动不动就clear一下,zoom:1一下。 对于你这个问题,absolute外圈要用relativer之流,而非fixed,ie低版本不认识这个。
    icyflash
        3
    icyflash  
       2012-02-24 21:56:36 +08:00
    而且应该不是IE的问题,absolute外层不是relative的话,就直接相对于body去定位了。
    icyflash
        4
    icyflash  
       2012-02-24 21:58:14 +08:00
    事实上firefox和ie的显示一样的,chrome dev版nav-home却是相对于page定位的,这倒有点奇怪
    benzhe
        5
    benzhe  
       2012-02-24 22:26:58 +08:00
    id为nav-home的div,既然用了position:absolute,那定位就不应该用margin,应该使用top,right,bottom,left。改成这样应该就好了:

    <div id="nav-home" style="background-color: White; width: 30%; height: 100px; top: 40%;
    left: 35%; z-index: 1000; position: absolute;">

    不过如果LZ纯粹想吐槽IE的兼容问题...嗯,IE这个陷阱很深,当心走不出来...
    Eysa
        6
    Eysa  
    OP
       2012-02-25 12:52:45 +08:00
    问题搞定了... 不应该使用 margin 啦...
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1845 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 00:58 · PVG 08:58 · LAX 17:58 · JFK 20:58
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.