In a recent project, I created a setup that involves two forms and a topper. The topper is always visible, and using flexbox, we split it into two halves. By adding an onclick() event in JavaScript, we can toggle between displaying the signup form and login form based on whether the user clicks on the signup header or the login header. It's important to understand how this code works and try implementing it on your own rather than just copying and pasting it - this approach aids in learning front-end development effectively.
function formSelector(selector) {
let signupElement = document.getElementById("signup")
let loginElement = document.getElementById("login")
let signupForm = document.getElementById("signupForm")
let loginForm = document.getElementById("loginForm")
if (selector == "signup") {
signup.classList.add("selectedHeader")
login.classList.remove("selectedHeader")
signupForm.classList.add("showForm")
loginForm.classList.remove("showForm")
}
else if (selector == "login") {
signup.classList.remove("selectedHeader")
login.classList.add("selectedHeader")
signupForm.classList.remove("showForm")
loginForm.classList.add("showForm")
}
}
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@200&display=swap");
body {
margin: 0;
padding: 0;
font-family: "poppins", "sans-serif";
overflow-x: hidden;
overflow-y: scroll;
--primary: rgb(4, 214, 4);
--primaryShade: rgb(15, 15, 15);
--secondaryShade: rgb(238, 240, 243);
scroll-behavior: smooth;
scroll-padding: 300px;
}
.formContainer {
background: var(--secondaryShade);
min-height: 100vh;
display: flex;
align-items: center;
transition: all 0.3s;
}
// Remaining CSS code
// HTML code section