Welcome to my website U-GINE MEDIA. In this website I teach tutorials and share source code on some programming (HTML, CSS & JavaScript) tutorials.
Before we get started, do well to subscribe to my channel to never miss out on any update that I post every single day.
You can also visit my GitHub where I upload all the code I have.
In this tutorial topic "Modern Sign Up Form with Javascript mousemove effect", we will learn how to create it following these simple easy steps.
Share this to your programmer friends. If y'all learnt something today, make sure to let me in the comments.
If interested in watching the video before running the code below, you can click the play button to get started.
Code Begins
- First, create a folder with any name you like. Then, make the necessary files inside it.
- Create a file called index.html to serve as the main file.
- Create a file called style.css for the CSS code.
- Create a file called script.js for the JavaScript code.
- Finally, go to FontAwesome and embed their cdnjs library link to your main file
To start, add the following HTML codes to your index.html file. These codes include essential HTML markup with different semantic tags, such as div, form, input, button, image, etc., to build the website layout.
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="index.css">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Modern Sign Up Form with Javascript mousemove effect</title>
</head>
<body>
<div class="container"></div>
<div class="cursor"></div>
<!--O2-->
<div class="container2">
<form>
<h2>Sign Up</h2>
<input type="email" placeholder="Email Address">
<input type="text" placeholder="Username">
<input type="password" placeholder="Password">
<input type="submit" value="Create Account">
<div class="sub">
<a href="">Already had an account?</a>
<a href="">Login</a>
</div>
</form>
</div>
</body>
</html>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: #000;
overflow: hidden;
}
.container {
display: grid;
grid-template-columns: repeat(15, 100px);
gap: 4px;
}
.container span {
position: relative;
width: 100px;
height: 70px;
background: #111;
z-index: 10;
}
.container span::before {
content: "";
position: absolute;
width: 50%;
height: 100%;
background: rgba(255,255,255,0.05);
}
.cursor {
position: absolute;
width: 300px;
height: 300px;
background: #0f0;
transform: translate(-50%,-50%);
z-index: 1;
border-radius: 50%;
animation: animate 4s linear infinite;
&::before,
&::after {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #0f0;
border-radius: 50%;
}
}
@keyframes animate {
0% {
filter: hue-rotate(0) blur(50px);
}100% {
filter: hue-rotate(360deg) blur(50px);
}
}
.container2 {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
z-index: 1000;
& form {
width: 400px;
background: #111;
backdrop-filter: blur(10px);
padding: 40px 20px;
border-radius: 5px;
& h2 {
color: #fff;
text-align: center;
font-family: Open Sans, sans-serif;
font-size: 2em;
margin-bottom: 30px;
}
& > input {
display: block;
width: 100%;
margin-bottom: 20px;
padding: 15px;
outline: none;
border: none;
background: rgba(255,255,255,.1);
border-radius: 3px;
color: #fff;
}
& > input::placeholder {
color: #fff;
font-size: 1.05em;
}
& > input[type="submit"] {
font-size: 1em;
background: #0f0;
color: #000;
cursor: pointer;
font-weight: 550;
}
& .sub {
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 30px;
& a {
text-decoration: none;
font-family: Open Sans, sans-serif;
color: #fff;
font-size: 0.8em;
}
& a:first-child {
color: #fff;
font-size: 0.9em;
&:hover {
text-decoration: underline;
}
}
& a:last-child {
background: #0f0;
padding: 10px 15px;
border-radius: 3px;
color: #000;
font-weight: 550;
}
}
}
}
Finally, add the following JavaScript code to your script.js file to make your work functional. This code handles various functions, even listeners, input handling, etc.
<script>
for(var i = 0; i < 250; i++) {
let box = document.createElement("span");
document.querySelector(".container").appendChild(box)
}
let cursor = document.querySelector(".cursor");
window.addEventListener("mousemove", e => {
cursor.style.left = e.clientX + "px";
cursor.style.top = e.clientY + "px"
})
</script>
0 Comments
We are happy to hear from you.