Проверьте этот код. Вам не нужно использовать position: absolute
, если изображение помещено в родительский элемент (в моем примере div.image
является родительским для div.content
).
* {
box-sizing: border-box;
}
body {
margin: 0;
}
.image {
min-height: 100vh;
background-image: url(https://miro.medium.com/max/1200/1*mk1-6aYaf_Bes1E3Imhc0A.jpeg);
background-size: cover;
background-repeat: no-repeat;
padding: 30px;
}
.content {
background: white;
padding: 15px;
border-radius: 3px;
}
<div class="image">
<div class="content">
<h1>What is Lorem Ipsum?</h1>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing
software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
</div>
Если вы хотите отобразить изображение на теле документа, вы можете добавить image
класс к <body>
вместо создания контейнера div.