代码之家  ›  专栏  ›  技术社区  ›  Jaanus

CSS:为什么只在Webkit中设置页边空白?

  •  1
  • Jaanus  · 技术社区  · 14 年前

    Here is a test case/live example. 问题摘要:

    这仅适用于WebKit:

    Y.one('#container').setStyle('margin-top', 100);
    

    Y.one('#container').setStyle('margin', 100);
    

    为什么设置页边空白只在WebKit中起作用?

    编辑:修复显示在下面的一个答案中。你需要把玛金托普放在这里,然后它就可以工作了。所以,编辑后的问题是,在这种情况下,为什么需要marginTop而不是marginTop?

    3 回复  |  直到 14 年前
        1
  •  2
  •   Robert    14 年前

    这在firefox中对我有用:

    <div id="nav">
    <a href='#' onclick='document.getElementById("nav").style.marginTop="25px";'>test</a>
    </div>
    
        2
  •  3
  •   Andris    14 年前

    如果您正在访问 style 那么,财产呢 by the standard 骆驼案适用。如果webkit支持smth-like element.style["margin-top"]

    简言之- marginTop 是的一部分 CSS2Properties margin-top 不是。

        3
  •  2
  •   Strelok    14 年前

    一定是的 marginTop ,因为您没有在CSS文件中设置CSS属性。您正在设置 style - 是标识符的无效字符。