Skip to content

Commit

Permalink
Form added
Browse files Browse the repository at this point in the history
  • Loading branch information
Adyasha8105 committed Jan 9, 2021
1 parent 0ea9a34 commit 5dd986f
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 54 deletions.
36 changes: 21 additions & 15 deletions Day8 - Form Wave/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,29 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="style.css" />
<title>Scroll Animation</title>
<title>Form Input Wave</title>
</head>
<body>
<h1>Scroll to see the animation</h1>
<div class="box"><h2>Content</h2></div>
<div class="box"><h2>Content</h2></div>
<div class="box"><h2>Content</h2></div>
<div class="box"><h2>Content</h2></div>
<div class="box"><h2>Content</h2></div>
<div class="box"><h2>Content</h2></div>
<div class="box"><h2>Content</h2></div>
<div class="box"><h2>Content</h2></div>
<div class="box"><h2>Content</h2></div>
<div class="box"><h2>Content</h2></div>
<div class="box"><h2>Content</h2></div>
<div class="box"><h2>Content</h2></div>
<div class="box"><h2>Content</h2></div>
<div class="container">
<h1>Please Login</h1>
<form>

<div class="form-control">
<input type="text" required>
<label>Email</label>
</div>

<div class="form-control">
<input type="password" required>
<label>Password</label>
</div>

<button class="btn">Login</button>

<p class="text">Don't have an account? <a href="#">Register</a> </p>

</form>
</div>
<script src="script.js"></script>
</body>
</html>
21 changes: 7 additions & 14 deletions Day8 - Form Wave/script.js
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('')
})
103 changes: 78 additions & 25 deletions Day8 - Form Wave/style.css
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);
}

0 comments on commit 5dd986f

Please sign in to comment.