viewport-units

Is it possible to calculate the Viewport Width (vw) without scrollbar?

∥☆過路亽.° 提交于 2019-11-27 05:09:37
问题 As mentioned in the title, is it possible to calculate the vw without the scrollbars in css only? For example, my screen has a width of 1920px . vw returns 1920px , great. But my actual body width is only something like 1903px . Is there a way for me to retrieve the 1903px value with css only (not only for direct children of the body ), or do I absolutely need JavaScript for this? 回答1: One way to do this is with calc. As far as i know, 100% is the width including scrollbars. So if you do:

CSS: Are view height (vh) and view width (vw) units widely supported?

流过昼夜 提交于 2019-11-27 04:02:14
I'm using 100vh to center a div vertically with line-height. This site puts support for vh and vw at around 70%, is that a fair assessment? Would you recommend using viewport units when building a site? I know this is a bit subjective, I'm just looking for opinions from more experienced web developers than I. EDIT: Thanks for the input everyone, I do want it to look good on mobile, so I guess I'll have to forgo vh. CodeFanatic The statistic is clearly and it is a fair assessment, in my point of view. I think the decision has to be made by you. If you want to future-proof your website using the

CSS Calc Viewport Units Workaround?

三世轮回 提交于 2019-11-26 15:44:23
问题 From what I've seen in other answers, CSS viewport units can't be used in calc() statements yet. What I would like to achieve is the following statement: height: calc(100vh - 75vw) Is there some workaround way I can achieve this using purely CSS even though the viewport units can't be used in the calc() statement? Or just CSS and HTML? I know I can do it dynamically using javascript, but I'd prefer CSS. 回答1: Before I answer this, I'd like to point out that Chrome and IE 10+ actually supports

CSS3 100vh not constant in mobile browser

烈酒焚心 提交于 2019-11-26 11:59:44
I have a very odd issue... in every browser and mobile version I encountered this behavior: all the browsers have a top menu when you load the page (showing the address bar for example) which slide up when you start scrolling the page. 100vh sometimes is calculated only on the visible part of a viewport, so when the browser bar slide up 100vh increases (in terms of pixels) all layout re-paint and re-adjust since the dimensions have changed a bad jumpy effect for user experience How can avoid this problem? When I first heard of viewport-height I was excited and I thought I could use it for

CSS: Are view height (vh) and view width (vw) units widely supported?

我只是一个虾纸丫 提交于 2019-11-26 11:02:00
问题 I\'m using 100vh to center a div vertically with line-height. This site puts support for vh and vw at around 70%, is that a fair assessment? Would you recommend using viewport units when building a site? I know this is a bit subjective, I\'m just looking for opinions from more experienced web developers than I. EDIT: Thanks for the input everyone, I do want it to look good on mobile, so I guess I\'ll have to forgo vh. 回答1: The statistic is clearly and it is a fair assessment, in my point of

CSS Units - What is the difference between vh/vw and %?

眉间皱痕 提交于 2019-11-26 04:39:17
问题 I just learned about a new and uncommon CSS unit. vh and vw measure the percentage of height and width of the viewport respectively. I looked at this question from Stack Overflow, but it made the units look even more similar. How does vw and vh unit works The answer specifically says vw and vh are a percentage of the window width and height, respectively: 100vw is 100% of the width, 80vw is 80%, etc. This seems like the exact same as the % unit, which is more common. In Developer Tools, I