Currently, I am focusing on practicing basic CSS. My goal is to achieve a specific layout for the header of a webpage that resembles this image with a wide top margin: wide top margin.
Here is the HTML code I am working with:
<div class="header">
.
.
.
</div>
<div class="page">
<div class="page-inside">
<div class="row-apps">
<div class="row-apps-item">
<img src="02.jpg" class="row-apps-img">
Kurikulum
</div>
<div class="row-apps-item">
<img src="03.jpg" class="row-apps-img">
Status Mahasiswa
.
.
.
</div>
</div>
</div>
</div>
And here is the associated CSS code:
.page {
height: 1000px;
padding: 0;
background-color:rgb(31, 31, 31);
}
.page-inside {
width: 1000px;
margin: 30px auto;
}
.row-apps {
padding: 10px;
overflow: hidden;
}
.row-apps-item {
color: rgb(57, 57, 207);
width: 16.66%;
float: left;
padding: 5px 10px;
}
My intention is to have a 30px space between .page
and .page-inside
containers, both of which have a black background. However, upon implementation, I noticed that the space appears between .header
and .page-inside
instead, resulting in a broken top margin like shown here: broken top margin. Through Chrome dev tools, I confirmed that the white space is indeed coming from .page-inside
and not from header
or .page
.
Although I could simply add padding to either .page-inside
or .row-items
to fix the issue, I believe that adding margin should also achieve the desired result. What am I misunderstanding in this scenario?