gpt4 book ai didi

html - 如何使背景为浏览器高度 100% 的 DIV 中没有任何内容或内容较少

转载 作者:行者123 更新时间:2023-11-28 08:39:58 24 4
gpt4 key购买 nike

我有密码

<html>
<head></head>
<body>
<div id="main"> Hello world.!</div>
</body>
</html>

和CSS

body{
background-color: black;
}

#main{
padding: 10px;
background-color: blue;
}

请帮我弄个 100% 高度的背景。寻找 jsfiddle 链接。

最佳答案

.center-element {
min-height: 100%;
min-height: 50vh;
display: flex;
align-items: center;
justify-content: center;
-ms-flex-direction: column;
flex-direction: column;
}

关于html - 如何使背景为浏览器高度 100% 的 DIV 中没有任何内容或内容较少,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27854984/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com