css div在另一个div中垂直居中

2022-04-25  本文已影响0人  Aurora_9e36
image.png

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(runoob.com)</title>
<style>
body {
background-color:#d0e4fe;
}
.f{
width:500px;
height:500px;
display: flex;
border:1px solid red;
justify-content: center;
align-items: center;
}
.c{
width:200px;
height: 200px;
border:1px solid red;
display: flex;
justify-content: center;
align-items: center;
}
</style>
</head>

<body>

<div class="f">
    <div class="c">垂直居中</div>
</div>

</body>

上一篇 下一篇

猜你喜欢

热点阅读