CSS计算宽度和高度值

KBE*_*KBE 3 html css html5 css3

如何使用CSS计算屏幕高度并将返回值用于宽度计算?有可能吗?

myClass{    
    height: calc(50% - 33.5px);
    width: heightReturnedValue*1.3
}
Run Code Online (Sandbox Code Playgroud)

Joh*_*hey 5

是的,在CSS中有一个叫做vh(视口高度)和vw(视口宽度)的东西。视口就是屏幕。

myClass {    
  height: calc(50% - 33.5px);
  width:  calc(100vh * 1.3);
}
Run Code Online (Sandbox Code Playgroud)