开发者

Question on CSS viewport width/height

I have 3 questions related to viewport;

  1. Do docu开发者_运维技巧ment.documentElement.clientWidth and -Height always gives the viewport dimensions, regardless of the dimensions of the element ?

  2. Can we both get and set width for the html element ? If yes, can this be done both using CSS and JS ?

  3. Is there a CSS exception to the rule that "document.documentElement.clientWidth and -Height still gives the dimensions of the viewport, and not of the element "


  1. it should always return the dimension of the viewport regardless of styles applied to the html element.

  2. you can't set it. As this would require the browser-window to resize too. You can resize the window using JS but you shouldn't do that. You can change the height and width of the html element with css, but that doesn't change the clientWidth.

  3. if you want to get the actual width of the html element use document.documentElement.offsetWidth

mobile is a bit of a different story.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜