Question on CSS viewport width/height
I have 3 questions related to viewport;
Do docu开发者_运维技巧ment.documentElement.clientWidth and -Height always gives the viewport dimensions, regardless of the dimensions of the element ?
Can we both get and set width for the html element ? If yes, can this be done both using CSS and JS ?
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 "
it should always return the dimension of the viewport regardless of styles applied to the html element.
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.
if you want to get the actual width of the html element use document.documentElement.offsetWidth
mobile is a bit of a different story.
精彩评论