Can I scale a div's height proportionally to its width using CSS?

前端 未结 9 1127
面向向阳花
面向向阳花 2020-12-07 16:34

Can I set any variable in CSS like I want my div height to always be half of width my div scales with the screen size width for div is in percent

9条回答
  •  感情败类
    2020-12-07 17:00

    You can use the view width to set the height. 100 vw is 100% of the width. height: 60vw; would make the height 60% of the width.

提交回复
热议问题