我有一个宽度为 50vw 的 div,所有边的内边距为 25px。我需要在它的右侧添加一个元素固定,所以我需要添加 50vw 和 25px。是否可以在纯 css 中这样做,还是我应该少用?如果我必须这样做,该怎么做?
最佳答案
I need to add 50vw and 25px
这就是calc
是为了。
The calc() CSS function lets you perform calculations when specifying CSS property values. It can be used anywhere a
<length>
,<frequency>
,<angle>
,<time>
,<number>
, or<integer>
is allowed.
width:calc(50vw + 25px);
关于html - 如何在CSS中添加带像素的视口(viewport)宽度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47954608/