diff --git a/index.html b/index.html index 846cf93..eb87679 100644 --- a/index.html +++ b/index.html @@ -1,12 +1,116 @@ - + - - - Практика позиционирования - - - - - - - \ No newline at end of file + + + + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + + + + + + + diff --git a/index.js b/index.js index dd50919..8812414 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,58 @@ -/* - Изменить элементу цвет и ширину можно вот так: +const element = document.querySelector('.progress-fill'); +const progressBar = document.querySelector('.progress-bar'); +const whiteText = document.querySelector('.progress-text-white'); - const element = document.querySelector('.myElement'); - element.style.color = 'red'; - element.style.width = '300px'; -*/ \ No newline at end of file +function startProgressBar() { + element.style.transition = 'none'; + element.style.width = '0%'; + whiteText.style.clipPath = 'inset(0 100% 0 0)'; + + setTimeout(() => { + element.style.transition = 'width 3s'; + element.style.width = '100%'; + updateWhiteText(); + }, 10); +} + +function updateWhiteText() { + const progressWidth = element.offsetWidth / progressBar.offsetWidth * 100; + whiteText.style.clipPath = `inset(0 ${100 - progressWidth}% 0 0)`; + + if (progressWidth < 100) { + requestAnimationFrame(updateWhiteText); + } +} + +const closeButton = document.querySelector('.modal-close'); +closeButton.addEventListener('click', () => { + const modal = document.querySelector('.modal'); + const overlay = document.querySelector('.modal-overlay'); + + modal.classList.add('hidden'); + overlay.classList.add('hidden'); +}); + +const openModalBtn = document.getElementById('openModalBtn'); +openModalBtn.addEventListener('click', () => { + const modal = document.querySelector('.modal'); + const overlay = document.querySelector('.modal-overlay'); + + modal.classList.remove('hidden'); + overlay.classList.remove('hidden'); + + startProgressBar(); +}); + + +const logos = document.querySelectorAll('.logo-wrapper'); +logos.forEach(logo => { + logo.addEventListener('click', () => { + const modal = document.querySelector('.modal'); + const overlay = document.querySelector('.modal-overlay'); + + modal.classList.remove('hidden'); + overlay.classList.remove('hidden'); + + startProgressBar(); + }); +}); \ No newline at end of file diff --git a/styles.css b/styles.css index e69de29..d52c975 100644 --- a/styles.css +++ b/styles.css @@ -0,0 +1,259 @@ +body { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + min-height: 100vh; + margin: 0; + gap: 40px; +} + +.container { + display: flex; + gap: 40px; +} + +.logo-wrapper { + width: 100px; + height: 100px; + background-color: white; + display: flex; + justify-content: center; + align-items: center; + border: 1px solid #ccc; +} + +.logo-microsoft { + width: 80px; + height: 80px; + display: grid; + grid-template-columns: 1fr 1fr; + grid-template-rows: 1fr 1fr; + gap: 4px; +} + +.square { + width: 100%; + height: 100%; +} + +.red { + background-color: #f3582e; +} + +.green { + background-color: #6a9709; +} + +.blue { + background-color: #0c93d1; +} + +.yellow { + background-color: #fcbe11; +} + +.logo-target { + width: 90px; + height: 90px; + background-color: red; + border-radius: 50%; + display: flex; + justify-content: center; + align-items: center; +} + +.target-white-ring { + width: 60px; + height: 60px; + background-color: white; + border-radius: 50%; + display: flex; + justify-content: center; + align-items: center; +} + +.target-center { + width: 30px; + height: 30px; + background-color: #e80018; + border-radius: 50%; +} + +.modal-overlay { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + display: flex; + justify-content: center; + align-items: center; + z-index: 1000; + opacity: 1; + visibility: visible; + transition: + opacity 0.3s ease, + visibility 0.3s ease; +} + +.modal-overlay.hidden { + opacity: 0; + visibility: hidden; +} + +.modal { + position: relative; + width: 640px; + background-color: white; + border-radius: 5px; + box-shadow: 0 0 10px gray; + padding: 20px; + opacity: 1; + transform: scale(1); + transition: + opacity 0.3s ease, + transform 0.3s ease; +} + +.modal.hidden { + opacity: 0; + transform: scale(0.9); +} + +.modal-close { + position: absolute; + top: 10px; + right: 10px; + font-size: 24px; + border: none; + background: none; + cursor: pointer; + padding: 0; + line-height: 1; + width: 30px; + height: 30px; + border-radius: 50%; +} + +.modal-close:hover { + background-color: lightgrey; +} + +.modal-content { + max-width: 100%; +} + +.progress-container { + margin-top: 20px; + width: 100%; +} + +.progress-bar { + position: relative; + height: 30px; + background-color: lightgrey; + border-radius: 4px; + overflow: hidden; +} + +.progress-fill { + position: absolute; + top: 0; + left: 0; + height: 100%; + width: 0%; + background-color: red; + transition: width 3s; +} + +.progress-text { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + display: flex; + align-items: center; + justify-content: center; + color: black; + z-index: 1; +} + +.progress-text-white { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + display: flex; + align-items: center; + justify-content: center; + color: white; + z-index: 2; + clip-path: inset(0 100% 0 0); +} + +.accordeon { + margin-top: 30px; + border: 1px solid whitesmoke; + border-radius: 4px; + overflow: hidden; +} + +.accordeon-item { + border-bottom: 1px solid whitesmoke; +} + +.accordeon-item:last-child { + border-bottom: none; +} + +.accordeon-toggle { + position: absolute; + opacity: 0; + z-index: -1; +} + +.accordeon-title { + display: block; + padding: 15px; + font-weight: bold; + background-color: whitesmoke; + cursor: pointer; + position: relative; +} + +.accordeon-title::after { + content: "+"; + position: absolute; + right: 15px; + top: 50%; + transform: translateY(-50%); + font-size: 20px; + transition: none; +} + +.accordeon-toggle:checked ~ .accordeon-title::after { + content: "+"; + animation: rotate-plus 0.3s forwards; +} + +.accordeon-toggle:not(:checked) ~ .accordeon-title::after { + content: "+"; + animation: rotate-minus 0.3s forwards; +} + +.accordeon-content { + max-height: 0; + overflow: hidden; + padding: 0 15px; + transition: + max-height 0.3s ease, + padding 0.3s ease; +} + +.accordeon-toggle:checked ~ .accordeon-content { + max-height: 500px; + padding: 15px; +}