JSFiddle - React, Tailwind, and code Playground
by Wentz Wu
HTML
<div id="wrapper">
<div>
<p>this is line 1</p>
</div>
<div id="box2">
<div id="box2a">
<p>this is line 2</p>
<p>this is line 2</p>
<div>test</div>
</div>
</div>
</div>
CSS
#wrapper {
position: relative;
top: 50px;
left: 50px;
width: 400px;
height: 200px;
padding: 5px;
border: 1px red solid;
}
#wrapper div {
border: 1px red solid;
margin: 5px;
padding: 5px;
width: 150px;
height: 150px;
background-color: grey;
}
#wrapper div:nth-child(2) {
background-color: red;
float: right;
position: relative;
top: -90px;
right: 50px;
z-index: -1;
}
/* 若selector使用#box2,其style不人會生效; 因為#wrapper div設定會優先 */
#wrapper div:nth-child(2) div {
background-color: white;
width: 100px;
height: 100px;
text-align: center;
vertical-align: middle;
display:table-cell;
}
#wrapper div:nth-child(2) div div:first-of-type {
background-color:blue;
width: 30px;
height: 30px;
display: block;
margin-left: auto;
margin-right: auto;
}
p {
margin: 0;
}