forked from Adyasha8105/30Projects30Days
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0ea9a34
commit 5dd986f
Showing
3 changed files
with
106 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,8 @@ | ||
const boxes = document.querySelectorAll('.box') | ||
window.addEventListener('scroll', checkBoxes) | ||
checkBoxes() | ||
function checkBoxes() { | ||
const triggerBottom = window.innerHeight / 5 * 4 //trigger point | ||
const labels = document.querySelectorAll('.form-control label') | ||
|
||
boxes.forEach(box => { | ||
const boxTop = box.getBoundingClientRect().top //returns a DOMReact object providing information about the size of an element and its position | ||
if(boxTop < triggerBottom) { | ||
box.classList.add('show') | ||
} else { | ||
box.classList.remove('show') | ||
} | ||
}) | ||
} | ||
labels.forEach(label => { | ||
label.innerHTML = label.innerText | ||
.split('') | ||
.map((letter, idx) => `<span style="transition-delay:${idx * 50}ms">${letter}</span>`) | ||
.join('') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,101 @@ | ||
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap'); | ||
@import url('https://fonts.googleapis.com/css?family=Muli&display=swap'); | ||
|
||
* { | ||
box-sizing: border-box; | ||
} | ||
|
||
body { | ||
background-color: #0f96cc; | ||
font-family: 'Roboto', sans-serif; | ||
background-color: rgb(46, 128, 196); | ||
color: #fff; | ||
font-family: 'Muli', sans-serif; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
height: 100vh; | ||
overflow: hidden; | ||
margin: 0; | ||
overflow-x: hidden; | ||
} | ||
|
||
h1 { | ||
margin: 10px; | ||
font-size: 20px; | ||
.container { | ||
background-color: rgba(23, 59, 88, 0.4); | ||
padding: 20px 40px; | ||
border-radius: 5px; | ||
} | ||
|
||
.container h1 { | ||
text-align: center; | ||
margin-bottom: 30px; | ||
} | ||
|
||
.container a { | ||
text-decoration: none; | ||
color: rgb(64, 128, 150); | ||
} | ||
|
||
.btn { | ||
cursor: pointer; | ||
display: inline-block; | ||
width: 100%; | ||
background: lightblue; | ||
padding: 15px; | ||
font-family: inherit; | ||
font-size: 16px; | ||
border: 0; | ||
border-radius: 5px; | ||
} | ||
|
||
.btn:focus { | ||
outline: 0; | ||
} | ||
|
||
.btn:active { | ||
transform: scale(0.98); | ||
} | ||
|
||
.text { | ||
margin-top: 30px; | ||
} | ||
|
||
.form-control { | ||
position: relative; | ||
margin: 20px 0 40px; | ||
width: 300px; | ||
} | ||
|
||
.box { | ||
background-color: #1554b3; | ||
.form-control input { | ||
background-color: transparent; | ||
border: 0; | ||
border-bottom: 2px #fff solid; | ||
display: block; | ||
width: 100%; | ||
padding: 15px 0; | ||
font-size: 18px; | ||
color: #fff; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
width: 350px; | ||
height: 250px; | ||
margin: 10px; | ||
border-radius: 10px; | ||
box-shadow: 2px 4px 5px rgba(0, 0, 0, 0.3); | ||
transform: translateX(400%); /* no card is shown (odd ones)*/ | ||
transition: transform 0.4s ease; | ||
} | ||
|
||
.box:nth-of-type(even) { | ||
transform: translateX(-400%); /* all the even cards */ | ||
.form-control input:focus, | ||
.form-control input:valid { | ||
outline: 0; | ||
border-bottom-color: lightblue; | ||
} | ||
|
||
.form-control label { | ||
position: absolute; | ||
top: 15px; | ||
left: 0; | ||
pointer-events: none; | ||
} | ||
|
||
.box.show { | ||
transform: translateX(0); /* card is shown */ | ||
.form-control label span { | ||
display: inline-block; | ||
font-size: 18px; | ||
min-width: 5px; | ||
transition: 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55); | ||
} | ||
|
||
.box h2 { | ||
font-size: 25px; | ||
.form-control input:focus + label span, | ||
.form-control input:valid + label span { | ||
color: lightblue; | ||
transform: translateY(-30px); | ||
} |