How to set width of a div in percent in JavaScript?

后端 未结 7 904
我寻月下人不归
我寻月下人不归 2020-12-09 08:09

Is it possible to set the height/width of an element in percent using JavaScript or jQuery?

7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-09 08:56

    document.getElementById('header').style.width = '50%';
    

    If you are using Firebug or the Chrome/Safari Developer tools, execute the above in the console, and you'll see the Stack Overflow header shrink by 50%.

提交回复
热议问题