css 如何在外部分割内部垂直居中对齐内部分割

drkbr07n  于 2023-01-06  发布在  其他
关注(0)|答案(2)|浏览(119)

假设有一个id=“innerDivision”的内分区,有一个id=“outerDivision”的外分区,外分区包围内分区,如何将内分区在外分区内部垂直居中对齐?
4.我试过了,但没有得到答复。请告诉妈妈答案

iqxoj9l9

iqxoj9l91#

#outerDivision {
  display: flex;
  background-color: gray;
  flex-direction: column;
  justify-content: center;
  height: 100px;
}

#innerDivision {
  background-color: red
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href="style.css" />
    <title>Browser</title>
</head>
<body>
    <div id="outerDivision">
        <div id="innerDivision">
            <span>innerDivision</span>
        </div>
    </div>
</body>
</html>
des4xlb0

des4xlb02#

#outerDivision {
  display: flex;
  background-color: gray;
  flex-direction: column;
  justify-content: center;
  height: 100px;
}

#innerDivision {
  background-color: red
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href="style.css" />
    <title>Browser</title>
</head>
<body>
    <div id="outerDivision">
        <div id="innerDivision">
            <span>innerDivision</span>
        </div>
    </div>
</body>
</html>

相关问题