Set element width or height in Standards Mode

后端 未结 2 1563
太阳男子
太阳男子 2020-12-13 03:05

Is it possible to set width or height of HTML element (ex.

) in JavaScript in Standards Mode?

Note the following code:



        
相关标签:
2条回答
  • 2020-12-13 03:32

    Try declaring the unit of width:

    e1.style.width = "400px"; // width in PIXELS
    
    0 讨论(0)
  • 2020-12-13 03:38

    The style property lets you specify values for CSS properties.

    The CSS width property takes a length as its value.

    Lengths require units. In quirks mode, browsers tend to assume pixels if provided with an integer instead of a length. Specify units.

    e1.style.width = "400px";
    
    0 讨论(0)
提交回复
热议问题