试图浮动元素或显示内联元素时,它们消失了。不知道为什么这是。这些属性似乎很简单。任何输入都很棒
body {
background-color: grey;
}
.divison1 {
background-color:blue;
min-width: 100px;
min-height: 100px;
}
.division2 {
background-color: green;
max-width: 100px;
min-height: 100px;
}
<!DOCTYPE>
<html>
<head>
<title> Practice with divs!</title>
<link href = "style.css" type = "text/css" rel = "stylesheet"/>
</head>
<body>
<div class = "divison1"></div>
</body>
</html>
将最大高点更改为最小
您的DIV的高度为0,因为它的空
body {
background-color: grey;
}
.divison1 {
background-color:blue;
min-width: 100px;
min-height: 100px;
}
<!DOCTYPE>
<html>
<head>
<title> Practice with divs!</title>
<link href = "style.css" type = "text/css" rel = "stylesheet"/>
</head>
<body>
<div class = "divison1"></div>
</body>
</html>
将max-height
更改为min-height
。max-height
仅将DIV的最大高度设置为100px,但是在这里您需要设置min-height
才能将某些内容纳入DIV
body {
background-color: grey;
}
.divison1 {
background-color:blue;
min-width: 100px;
min-height: 100px;
}
<!DOCTYPE>
<html>
<head>
<title> Practice with divs!</title>
<link href = "style.css" type = "text/css" rel = "stylesheet"/>
</head>
<body>
<div class = "divison1"></div>
</body>
</html>