I am busy with a very simple thing of CSS. Let´s say I have four squares and inside each another square. I want my layout to look something like this:
But it looks like this:
But I can't get it right. The four squares are grouped in one element and display is set to inline-block. I want to move the small boxes inside their parents and I think I should do it with "display: flex" and "justify-content: flex-end" for example as in the code below. My code in HTML and CSS look like this.
{
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
background-color: honeydew;
margin: 15px;
width: 100%;
}
.big {
height: 200px;
width: 200px;
display: flex;
}
.small {
height: 100px;
width: 100px;
}
.block {
display: inline-block;
}
#small-1 {
display: flex;
justify-content: flex-end;
align-items: flex-end;
}
#small-2 {
display: flex;
justify-content: flex-end;
align-items: flex-end;
}
#small-3 {
display: flex;
justify-content: flex-end;
align-items: flex-start;
}
#small-4 {
display: flex;
justify-content: flex-start;
align-items: flex-start;
}
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="stylesheet.css">
<title>Boxes</title>
</head>
<body>
<div class="block" id="block">
<div class="big" style="background-color: grey">
<div class="small" id="small-1" style="background-color:orange"></div>
</div>
</div>
<div class="block" id="block">
<div class="big" style="background-color: black">
<div class="small" id="small-2" style="background-color: yellow"></div>
</div>
</div>
<div class="block" id="block">
<div class="big" style="background-color: blue">
<div class="small" id="small-3" style="background-color: green"></div>
</div>
</div>
<div class="block" id="block">
<div class="big" style="background-color: purple">
<div class="small" id="small-4" style="background-color: pink"></div>
</div>
</div>
</body>
</html>
Can anybody help me with this? It seems pretty obvious and basic, but somehow doesn't work.