I want the two divs to be in the same position, but stuck to each other, which makes the hole for me, and I don't understand why it does it or how to remove it
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body {
margin: 0;
padding: 0;
}
header {
height: 4em;
width: 100%;
border: 3px solid #ccc;
}
main {
margin: 1px;
height: 25em;
width: 100%;
border: 3px solid #ccc;
display: flex;
align-items: center;
justify-content: flex-start
}
article {
height: 23em;
width: 22em;
border: 3px solid black;
margin-left: 5px;
display: flex;
justify-content: center;
flex-wrap: wrap;
}
.container-img {
height: 15em;
margin: 2px;
width: 18em;
border: 3px solid black;
}
.container-title {
height: 5em;
width: 18em;
border: 3px solid black;
}
</style>
</head>
<body>
<header></header>
<main>
<article>
<div class="container-img"></div>
<div class="container-title"></div>
</article>
</main>
</body>
</html>
You can do the following:
flex-wrap
to move the seconddiv
to the next line, you can implement the use offlex-direction
with a value ofcolumn
padding
to separate the 2div
from its edgediv
We give the second a defined width ( which, even when you put real content on it, will not be necessary ) and we achieve the desired appearanceCode:
Reference