M
M
Maxim Golovlev2021-07-11 13:35:00
css
Maxim Golovlev, 2021-07-11 13:35:00

How to properly position the position of an html element?

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="MAIN.CSS">
    <title>desolate</title>
</head>
<body>
<div class="aboutme">
<div class="avatar"></div>
<div class="nickname"></div>
<div class="info">
</div>
<video autoplay muted loop id="background-video">
<source src="image/Overlay_Start_01_2.webm" type="video/mp4"></video>
</body>
</html>


.background-video {
    position: absolute;
    right: 0;
    bottom: 0;
    min-width: 100%;
    min-height: 100%;
}

.aboutme {
    margin: 0 auto;
    width: 440px;
    height: auto;
}

.avatar {
    background-image: url(image/avatar.jpg);
    width: 126px;
    height: 126px;
    border-radius: 50%;
    margin: 170px auto 0px;
}

.nickname {
    background-image: url(image/nickname.png);
    width: 442px;
    height: 31px;
    margin: 24px auto 0px;
}

.info {
    width: 232px;
    height: auto;
    margin: 10px auto 0px;
    color: #8B8B8B;
    font-family: Montserrat;
    font-style: normal;
    font-weight: normal;
    font-size: 12px;
    line-height: 15px;
    text-align: center;
    letter-spacing: 0.1em;
}


We get:
60eac91d704ee338911749.png

How to correctly position the background-video so that the video goes to the background without affecting other elements?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
Wispik, 2021-07-11
@Wispik

You cram everything into a block with position: relative. Set the video block to position: absolute. The rest of the blocks are placed as needed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question