Как закрепить псевдоэлементы ::before и ::after , чтобы они не слетали при сужении окна браузера?
Как закрепить псевдоэлементы ::before и ::after , чтобы они не слетали при сужении окна браузера?
body {
background-color: darkred;
margin: 0 auto;
font-family: 'Fredoka One', cursive;
}
.container {
max-width: 980px;
height: auto;
position: relative;
margin: 20px auto;
}
.video-gallery {
max-width: 980px;
height: auto;
background-color: white;
border: 2px solid grey;
margin: 0 auto;
margin-top: 50px;
}
iframe {
float: right;
margin: 20px 15px;
border: 2px solid grey;
}
.clear {
clear: right;
}
h1 {
color: white;
text-align: center;
text-shadow: black 0 0 10px;
}
.container::before {
content: "";
width: 200px;
height: 200px;
background: url("https://i.ibb.co/4s4MtTC/cloud.png") no-repeat;
right: 150px;
bottom: 130px;
z-index: 2;
position: absolute;
transform: rotate(10deg)
}
.container::after {
content: "";
width: 500px;
height: 500px;
background: url("https://i.ibb.co/M59CxXV/oscar.png") no-repeat;
left: -140px;
bottom: -160px;
z-index: 6;
position: absolute;
transform: rotate(700deg)
}
.talk {
width: 90px;
height: 60px;
position: absolute;
right: 200px;
bottom: 220px;
background-color: white;
z-index: 4;
transform: rotate(30deg);
font-size: 20px;
}
<div class=container>
<img src="https://i.ibb.co/Yk0fX0P/chelovek.png" alt="">
<div class="talk">And Mihaloscar goes to...</div>
<h1>Лучшие обзоры BAD COMEDIAN</h1>
</div>https://ibb.co/T8WP1WY
<div class="video-gallery">
<iframe width="450" height="315" src="https://www.youtube.com/embed/1nX0kF2UwDc" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<iframe width="450" height="315" src="https://www.youtube.com/embed/pconHWXO3Ss" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<iframe width="450" height="315" src="https://www.youtube.com/embed/yeqYNOFQDVU" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<iframe width="450" height="315" src="https://www.youtube.com/embed/2_bWhf5SdtI" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<div class="clear"></div>
</div>
Ответы (1 шт):
Автор решения: Михаил Камахин
→ Ссылка
@import url("https://fonts.googleapis.com/css2?family=Fredoka+One&display=swap");
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
padding: 0;
}
html {
height: 100%;
}
body {
min-height: 100%;
font-family: "Fredoka One", cursive;
background-color: darkred;
}
img {
display: block;
max-width: 100%;
}
section {
padding: 80px 0;
}
.container {
max-width: 980px;
display: block;
margin: 0 auto;
padding: 0 15px;
width: 100%;
}
.video-gallery {
background-color: white;
border: 2px solid grey;
display: flex;
flex-direction: column;
--galeryWidth: 30px;
padding: var(--galeryWidth);
}
.video-gallery>*:not(:last-child) {
margin-bottom: var(--galeryWidth);
}
.section-wrapper>*:not(:last-child) {
margin-bottom: 20px;
}
.video-gallery iframe {
width: 100%;
display: block;
min-height: 400px;
border: 2px solid grey;
}
h1 {
color: white;
text-align: center;
text-shadow: black 0 0 10px;
}
.img-container {
position: relative;
overflow: hidden;
}
.img-container>.static-img>img {
width: 100%;
min-height: 400px;
object-fit: cover;
}
.talk {
width: 200px;
height: 150px;
background: url("https://i.ibb.co/4s4MtTC/cloud.png") no-repeat center;
background-size: contain;
position: absolute;
right: 0%;
top: 25%;
z-index: 4;
transform: rotate(30deg) scale(2);
font-size: 20px;
}
.talk span {
position: absolute;
bottom: 50%;
right: 50%;
transform: translate(57%, 30%)
}
.oskar {
position: absolute;
top: 0;
left: -10%;
transform-origin: center;
transform: rotate(-10deg) scale(0.8);
}
@media (max-width: 815px) {
.oskar {
left: -30%
}
.talk {
transform: rotate(30deg) scale(1.5);
}
}
<section>
<div class="container">
<div class="section-wrapper">
<div class="img-container">
<div class="static-img">
<img src="https://i.ibb.co/Yk0fX0P/chelovek.png">
</div>
<div class="talk">
<span>And Mihaloscar goes to...</span>
</div>
<div class="oskar">
<img src="https://i.ibb.co/M59CxXV/oscar.png">
</div>
</div>
<h1>Лучшие обзоры BAD COMEDIAN</h1>
<p>https://ibb.co/T8WP1WY</p>
<div class="video-gallery">
<iframe src="https://www.youtube.com/embed/1nX0kF2UwDc" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<iframe src="https://www.youtube.com/embed/pconHWXO3Ss" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<iframe src="https://www.youtube.com/embed/yeqYNOFQDVU" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<iframe src="https://www.youtube.com/embed/2_bWhf5SdtI" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
</div>
</div>
<!-- .container -->
</section>