Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 43 additions & 11 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,44 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Практика позиционирования</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<!--Верстать тут-->
<script src="index.js"></script>
</body>
</html>
<head>
<meta charset="UTF-8" />
<title>Практика позиционирования</title>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<div class="block1">
<img class="img1" src="designs/logo4.jpeg" />
</div>
<div class="block1">
<img class="img1" src="designs/logo1.png" />
</div>

<button class="open-button">Открыть модальное окно</button>

<div class="lightbox">
<h2>Модальное окно</h2>
<button class="x-button close-button">X</button>
<p>Текст модального окна</p>
<div class="progress">
<h2 style="text-align: center; z-index: 1003">Loading...</h2>
<div class="red-line" style="overflow: hidden">
<h2
style="
width: 52px;
color: white;
text-align: center;
z-index: 1003;
margin-left: 204px;
"
>
Loading...
</h2>
</div>
</div>
</div>

<div class="overlay"></div>

<script src="index.js"></script>
</body>
</html>
35 changes: 34 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,37 @@
const element = document.querySelector('.myElement');
element.style.color = 'red';
element.style.width = '300px';
*/
*/

document.querySelector(".close-button").addEventListener("click", (event) => {
const element = document.querySelector(".lightbox");
element.style.display = "none";

const element1 = document.querySelector(".overlay");
element1.style.display = "none";
});

document.querySelector(".open-button").addEventListener("click", (event) => {
const element = document.querySelector(".lightbox");
element.style.display = "flex";

const element1 = document.querySelector(".overlay");
element1.style.display = "block";

const redLine = document.querySelector(".red-line");
const totalSteps = 128;
const totalDuration = 3000;
const maxWidth = 512;
let step = 0;

redLine.style.width = "0px";

const timer = setInterval(() => {
step += 1;
redLine.style.width = (step * maxWidth) / totalSteps + "px";

if (step >= totalSteps) {
clearInterval(timer);
}
}, totalDuration / totalSteps);
});
68 changes: 68 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
.block1 {
width: 100px;
height: 100px;
overflow: hidden;
}

.img1 {
width: 100%;
height: 100%;
object-fit: contain;
}

.lightbox {
width: 640px;
display: none;
flex-direction: column;
background-color: ghostwhite;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
padding: 24px;
z-index: 1000;
}

.x-button {
width: 32px;
height: 32px;
background-color: transparent;
border: none;
font-size: 24px;
position: absolute;
top: 16px;
right: 16px;
cursor: pointer;
}

.h2 {
padding: 0;
}

.overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.7);
z-index: 999;
display: none;
}

.progress {
width: 512px;
position: relative;
background: gray;
overflow: hidden;
}

.red-line {
position: absolute;
top: 0;
left: 0;
width: 50%;
height: 100%;
background: red;
z-index: 1001;
}