Changing CSS Values with Javascript

后端 未结 9 1549
借酒劲吻你
借酒劲吻你 2020-11-22 17:16

It\'s easy to set inline CSS values with javascript. If I want to change the width and I have html like this:

<
9条回答
  •  盖世英雄少女心
    2020-11-22 17:48

    I've never seen any practical use of this, but you should probably consider DOM stylesheets. However, I honestly think that's overkill.

    If you simply want to get the width and height of an element, irrespective of where the dimensions are being applied from, just use element.offsetWidth and element.offsetHeight.

提交回复
热议问题