【问题标题】:Settling a margin left to half of the screen width将边距设置为屏幕宽度的一半
【发布时间】:2015-09-17 20:59:17
【问题描述】:

我正在为学校做一个项目,我需要将此按钮的边距设置为屏幕宽度的一半。它目前不工作:

document.getElementById("listStyle").style.marginLeft = ((screen.width) / 2) = "px";

按钮的id是listStyle。

谢谢!

【问题讨论】:

  • + 'px' 而不是 = 'px'

标签: javascript margin


【解决方案1】:
document.getElementById("listStyle").style.marginLeft = ((screen.width) / 2) **=** "px";

需要 + 而不是 =

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-07-16
    • 2013-07-17
    • 2014-02-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多