グレイ(親) "ラッパー" divの内側に、この "赤" div(div = "red")をどのように配置することができますか?私は、赤いdivがラッパーdivの中心(垂直方向と水平方向の両方)に正確に配置されるようにします。誰もこの赤いdivを中心にする方法を教えてくださいできますか?
body {
height: 100%;
width: 100%;
background-color: rgba(255, 249, 249, 1);
margin: 0px;
left: 0px;
top: 0px;
right: 0px;
bottom: 0px;
}
.wrapper {
background-color: rgba(204, 204, 204, 1);
height: 600px;
width: 100%;
margin: auto;
color: rgba(255, 255, 255, 1);
text-align: center;
font-weight: bold;
display: block;
position: relative;
top: 0px;
bottom: 0px;
left: 0px;
right: 0px;
}
.red {
background-color: rgba(255, 0, 0, 1);
height: 50%;
width: 600px;
position: absolute;
font-weight: normal;
text-align: left;
/* [disabled]line-height: 100px; */
display: block;
vertical-align: top;
/* [disabled]z-index: 1; */
left: 0%;
top: 0px;
margin-top: 0px;
margin-right: auto;
margin-bottom: auto;
margin-left: auto;
right: 0px;
bottom: 0px;
}
.green {
height: 200px;
width: 200px;
position: relative;
background-color: rgba(0, 255, 0, 1);
left: 0px;
top: 0px;
right: 0px;
bottom: 0px;
display: block;
/* [disabled]z-index: -1; */
margin: 0px;
clear: none;
}
.blue {
height: 200px;
width: 200px;
position: absolute;
background-color: rgba(0, 51, 153, 1);
left: 400px;
top: 20px;
right: 0px;
bottom: 100px;
display: block;
z-index: 1;
margin: 0px;
float: left;
}
<div class="wrapper">
Test
<div class="red">Red
<div class="green">Green</div>
<div class="blue">Blue</div>
</div>
</div>
すべてあなたがセンタリングについて知る必要があるのは、[素晴らしいCSS Tricksサイト](https://css-tricks.com/centering-css-complete-guide/) – nem035