<div id="parent">
<span id="text">Parent Container</span>
<div id="child">
<span id="text">padding: 5%</span>
<div id="content">
Content
</div>
</div>
</div>
body{
display: flex;
justify-content: center;
align-items: center;
background-color: #FB8C00;
font-family: sans-serif;
color: #fff;
height: 100vh;
}
#parent{
width: 400px;
height: 300px;
background-color: #fff;
position: relative;
resize: both;
overflow: hidden;
border-radius: 5px;
box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
#text{
color: #000;
width: 120%;
}
}
#child{
position: absolute;
top: 50%;
left:50%;
transform: translate(-50%, -50%);
width: 100px;
height: 100px;
background-color: #66BB6A;
padding: 5%;
resize: both;
overflow: hidden;
border-radius: 5px;
#text{
color: #fff;
}
}
#text{
position: absolute;
top: 2px;
left: 5px;
}
#content{
background-color: #03A9F4;
height: 100%;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
border-radius: 5px;
border: 1px solid #fff;
}
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.