Reputation: 1587
I have a site which contains a header image that I want to fit 70% of the screen height on all screens and on the remaining space I want to print some text.
Should I use javascript or should I use media-queries?
Where can I find the standard height parameters for which I have to write the media queries? I found the standard resolutions based on width here.
Upvotes: 1
Views: 587
Reputation: 2260
There is a vh
that will work for you. 1vh equals to 1% of browsers viewport. So if you set header{height:70vh;}
it will use 70% of what user can see.
Additional relative lengths:
There are more relative lengths than just vh
. There is:
vh
- Relative to 1% of the height of the viewportvw
- Relative to 1% of the width of the viewportvmin
- Relative to 1% of viewport's smaller dimensionvmax
- Relative to 1% of viewport's larger dimensionThese lengths are supported by all browsers, https://caniuse.com/#feat=viewport-units.
source: https://developer.mozilla.org/en-US/docs/Web/CSS/length
Upvotes: 4