使尺寸适合屏幕的高度

时间:2021-07-23 17:30:05

标签: css mobile background height screen

这肯定是一个微不足道的问题,但我已经困扰了很长时间。 问题很简单,即:我有一个具有特定尺寸 (450x800px) 的区域,我希望该区域始终适合屏幕的高度。

我在此附上我正在编写的示例代码,非常感谢能帮助我的人!

<!DOCTYPE html>
<html>
<head>
     <meta name="viewport" content="height=device-height, initial-scale=1.0">
<title>Page Title</title>
<style>
html, body {  height: 100%;  margin: 0;}
.full-height {  height: 100%;  background: yellow;}
</style>
</head>
<body>
<div class="full-height">
    <div style="width:450px; height:800px; margin-left:auto; margin-right:auto; background-color:#FD0F13">I am a DIV that will stretch to fit the whole width and height of the browser window!</div>
</div>
</body> </html>

0 个答案:

没有答案