The margin space between div1 and header is undesired white, even though I declared the background as grey (rgb:243,243,243). I want to get rid of the white space between div1 and header.
I tried different ways to fix that like changing the colours or adjust the margin and padding but nothing worked.
.header {
width: 100%;
height: 8.5vh;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 20px;
background-color: rgb(243, 243, 243);
z-index: 1000;
}
.header-fixed {
position: fixed;
}
.shadow {
box-shadow: 0px 0px 8px rgba(0, 0, 0, .6);
}
.header .logo {
margin-left: 2vh;
font-size: 1.5em;
text-decoration: none;
color: black;
}
.header ul {
margin-left: 2vh;
margin: 0;
padding: 0;
list-style: none;
}
.header li {
margin-right: 20px;
}
.header li:last-child {
margin-right: 0;
}
.header li a {
text-decoration: none;
color: black;
padding: 10px;
border-radius: 5px;
}
.header li a:hover {
background-color: #f4f4f4;
}
.header .logo {
font-size: 2em;
text-decoration: none;
color: black;
}
/* menu */
.header .menu {
top: 0;
position: sticky;
width: auto;
clear: both;
max-height: 0;
transition: max-height 0.2s ease-out;
margin-right: 3vh;
}
/* menu icon */
.header .menu-icon {
cursor: pointer;
display: inline-block;
position: absolute;
/* Geändert von 'float: right;' zu 'position: absolute;' */
right: 0;
/* Hinzugefügt, um das Icon rechts auszurichten */
padding: 28px;
padding-left: 5%;
-webkit-user-select: none;
user-select: none;
z-index: 1000;
/* Stellen Sie sicher, dass das Menü über anderen Elementen liegt */
}
.header .menu-icon .navicon {
background: #333;
display: block;
height: 2px;
position: relative;
transition: background 0.2s ease-out;
width: 18px;
}
.header .menu-icon .navicon:before,
.header .menu-icon .navicon:after {
background: #333;
content: "";
display: block;
height: 100%;
position: absolute;
transition: all 0.2s ease-out;
width: 100%;
}
.header .menu-icon .navicon:before {
top: 5px;
}
.header .menu-icon .navicon:after {
top: -5px;
}
/* menu btn */
.header .menu-btn {
display: none;
}
.header .menu-btn:checked~.menu {
max-height: 240px;
}
.header .menu-btn:checked~.menu-icon .navicon {
background: transparent;
}
.header .menu-btn:checked~.menu-icon .navicon:before {
transform: rotate(-45deg);
}
.header .menu-btn:checked~.menu-icon .navicon:after {
transform: rotate(45deg);
}
.header .menu-btn:checked~.menu-icon:not(.steps) .navicon:before,
.header .menu-btn:checked~.menu-icon:not(.steps) .navicon:after {
top: 0;
.div1 {
margin-top: 5vh;
margin-bottom: 2.5vh;
display: flex;
background-color: rgb(243, 243, 243);
flex-wrap: wrap;
gap: 2%;
/* Vertikaler und horizontaler Abstand zwischen den Elementen */
justify-content: space-between;
/* Sorgt für gleichmäßigen Abstand zwischen den Elementen und zum Rand */
height: 100vh;
padding-left: 2%;
padding-right: 2%;
}
.picture-container {
display: flex;
flex-direction: column;
margin-top: 0;
margin-bottom: 3vh;
flex: 1;
min-width: calc(50% - 2%);
height: 80%;
overflow: hidden;
/* Verhindert das "Auslaufen" von inneren Inhalten außerhalb der abgerundeten Ecken */
}
.img-container {
flex-grow: 1;
overflow: hidden;
/* Diese Zeile hinzugefügt */
background-color: #fff;
/* Hintergrundfarbe, passend zu Ihren Bildern oder der Website */
}
.img-container img {
object-fit: cover;
width: 100%;
height: 100%;
transition: transform 0.8s ease-in-out;
}
.footer {
background-color: white;
flex-shrink: 0;
/* Verhindert, dass der Footer schrumpft */
height: 13%;
/* Höhe des Footers, anpassbar nach Bedarf */
display: flex;
/* Erlaubt die Zentrierung von Inhalten im Footer */
align-items: center;
/* Zentriert den Inhalt vertikal */
}
.footer h3 {
font-size: 24px;
/* Größere Schriftgröße */
color: #000;
/* Stellt sicher, dass die Schriftfarbe kontrastreich genug ist */
padding: 20px;
/* Etwas Platz um den Text */
margin: 0;
/* Entfernt jeglichen Standardabstand */
font-weight: 300;
font-size: 30px;
/* Überschreibt vorherige Schriftgröße */
letter-spacing: 0.06em;
line-height: 50px;
}
}
<header class="header">
<a href="" class="logo">COMPANY</a>
<input class="menu-btn" type="checkbox" id="menu-btn" />
<label class="menu-icon" for="menu-btn"><span class="navicon"></span
></label>
<ul class="menu">
<li><a href="#about">ABOUT</a></li>
<li><a href="#contact">A</a></li>
<li><a href="#careers">B</a></li>
</ul>
</header>
<div class="div1">
<div class="picture-container">
<div class="img-container">
<img alt="Bild ist nicht verfügbar" src="https://allgemeinebauzeitung.de/media/_processed_/c/5/csm_peri-geruestbau-geruestbautechnik-naechste-generation-im-geruestbau-vereint-vorteile-von-rahmen-und-modul-45646-1_acfa19c3af.jpg" />
</div>
<div class="footer">
<h3>GERÜSTBAU</h3>
</div>
</div>
<div id="picture-container2" class="picture-container">
<div class="img-container">
<img alt="Bild ist nicht verfügbar" src="https://www.betriebsratspraxis24.de/wp-content/uploads/sites/52/2023/01/AdobeStock_283383067-1024x683.jpeg" />
</div>
<div class="footer">
<h3>BAU</h3>
</div>
</div>
</div>
You could add a background color to the body:
This will make your whole page a certain color.