관리 메뉴

Silver Library (Archived)

CSS - height, calc, vh? 본문

Face the fear, build the future/Revision Sector

CSS - height, calc, vh?

Chesed Kim 2022. 12. 11. 23:45
반응형

tl;dr - Let me know how height's vh, calc can be used as professional.

 

Note:

That means width: 100vw works. To let it fill the whole width, then use it so instead 100% width.

 

Sauce.

 

CSS `height: calc(100vh);` Vs `height: 100vh;`

I'm working on a project where the former developer used: .main-sidebar { height: calc(100vh); } I have no way to contact him/her anymore, and I would like to understand what is the differenc...

stackoverflow.com

VH
height: 100vh; means the height of this element is equal to 100% of the viewport height.

example: height: 50vh;
If your screen height is 1000px, your element height will be equal to 500px (50% of 1000px).

CALC
height: calc(100% - 100px); will calculate the size of the element by using the value of the element.

example:
height: calc(100% - 100px); If your screen height is 1000px, your element height will be equal to 900px (100% of 1000px and minus 100px).

*I think your former developer didn't need to use calc() if he/she didn't want to calculate value.