且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在css中限制屏幕的最大宽度和高度?

更新时间:2023-10-30 23:09:22

若要将高度和宽度设置为窗口(视区)大小的100%,请使用:

height: 100vh;//100% view height
width: 100vw;// 100% view width

数据-lang="js"数据-隐藏="假"数据-控制台="假"数据-巴贝尔="假">
div {
  background-color: blue;
  height: 100vh;
  width: 100vw;
  position: absolute;
  top: 0;
  left: 0;
  color: white;
}
<div>some content here</div>