css_居中:用flex
2018-11-27 本文已影响0人
壮壮成长记
<style type="text/css">
* {
margin: 0;
padding: 0;
}
/* body{
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
} */
body{
min-height: 100vh;
display: flex;
}
.parent{
margin:auto;
}
.parent {
display: flex;
align-items: center;
justify-content: center;
}
.parent {
width: 600px;
height: 600px;
background: #808080;
}
.child {
width: 30%;
height: 30%;
background: #DAA520;
}
</style>
</head>
<body>
<div class="parent">
<div class="child"></div>
</div>
</body>