How we can create an animated 404 page with a parallax effect using JS or any JS library? Solution: See this Parallax Error 404 Page Animation With CSS & JS, Move On Hover.
Previously I have shared some error 404 design, but this is different from others because it has a parallax effect on hover. Basically, when we click on a broken link of the website then we can see an error with 404 code. This code means page not found, most developers create a custom 404 page to navigating users to visit other links. If we did not put a custom error page on our website then we can’t see any other links to visit, then we have to go back. Nowadays most of the web 2.0 or CMS contains a custom error page.
Today you will learn to create an error page with move on hover. Basically, there are two circular gradients with overlay, some moving lines, and texts like 404, massage, and go to the home button. When you will move the mouse on the webpage, then elements will move according to and opposite the mouse cursor. All the elements move like a parallax effect, frond elements move faster and back slower.
So, Today I am sharing Parallax Error 404 Page Animation With CSS & JS. There I have used a dedicated JS library to create the parallax effect, and all other features are based on CSS. If you are an expert in CSS then you can create this kind of program, because there are many tricky CSS parts. This is a complete 404 page that you can use on your project or website.
If you are thinking now how this error page actually is, then see the preview given below.
Preview Of Page Not Pound Page Move On Hover
See this video preview to getting an idea of how this parallax design looks like.
Now you can see this visually, also you can see it live by pressing the button above. If you like this, then get the source code of its.
You May Also Like:
- Canvas Particle Animation
- jQuery Draggable Slider
- CSS jQuery Budget Slider
- CSS Border Transition Effects
Parallax Error 404 Page Animation With CSS & JS Source Code
Before sharing source code, let’s talk about it. First I have created the layout using HTML div, section, p, etc tags. I have created 3 content divs, and each div has 3 items for the moving lines. There I have used HTML Data-* element for storing custom data. Also in the HTML file, I have linked other files like CSS, JS, and library’s CDN.
Now using CSS I have placed all the elements in the right place, as you can see in the preview. With CSS I have done basic works like size, position, margin, padding, etc. I heavily used CSS @keyframe command for creating animation, and in the animation property I have used cubic-bezier() to define the animation curve. This is also a responsive design, for that used CSS @media query.
JS file has only 2 lines of code because there I used a dedicated library for parallax. I have used parallax.js for creating the parallax effect. And in JS file we just have to declare the element which we want to give the effect. Left all other things you will understand after getting the codes, I can’t explain all in writing.
For creating this program we have to create 3 files. First file for HTML, second for CSS, and the third for JavaScript. Follow the steps to creating this without any error.
index.html
Create an HTML file named ‘index.html‘ and put these codes given below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
<!DOCTYPE html> <!-- Code By Webdevtrick ( https://webdevtrick.com ) --> <html lang="en" > <head> <meta charset="UTF-8"> <title>Parallax Error 404 | Webdevtrick.com</title> <link rel="stylesheet" href="style.css"> </head> <body> <section class="wrapper"> <div class="container"> <div id="PRllax" class="PRllax" data-hover-only="false"> <div class="circle" data-depth="1.2"></div> <div class="one" data-depth="0.9"> <div class="content"> <span class="piece"></span> <span class="piece"></span> <span class="piece"></span> </div> </div> <div class="two" data-depth="0.60"> <div class="content"> <span class="piece"></span> <span class="piece"></span> <span class="piece"></span> </div> </div> <div class="three" data-depth="0.40"> <div class="content"> <span class="piece"></span> <span class="piece"></span> <span class="piece"></span> </div> </div> <p class="p404" data-depth="0.50">404</p> <p class="p404" data-depth="0.10">404</p> </div> <div class="text"> <article> <p>This page has not been found. <br>You have lost!</p> <button>go to home</button> </article> </div> </div> </section> <script src='https://cdnjs.cloudflare.com/ajax/libs/parallax/3.1.0/parallax.min.js'></script> <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="function.js"></script> </body> </html> |
style.css
Now create a CSS file named ‘style.css‘ and put these codes given here.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 |
/* Code By Webdevtrick ( https://webdevtrick.com ) */ @import url("https://fonts.googleapis.com/css?family=Josefin+Sans&display=swap"); h1,h2,h3,h4,h5,h6,p,ul,li,button,a,i,input,body { margin: 0; padding: 0; list-style: none; border: 0; -webkit-tap-highlight-color: transparent; text-decoration: none; color: inherit; } body { margin: 0; padding: 0; height: auto; font-family: 'Josefin Sans', sans-serif; background: #ff5757; } .wrapper { display: grid; grid-template-columns: 1fr; justify-content: center; align-items: center; height: 100vh; overflow-x: hidden; } .wrapper .container { margin: 0 auto; transition: all 0.4s ease; display: flex; justify-content: center; align-items: center; position: relative; } .wrapper .container .PRllax { position: absolute; width: 100vw; height: 100vh; vertical-align: middle; } .wrapper .container .one, .wrapper .container .two, .wrapper .container .three, .wrapper .container .circle, .wrapper .container .p404 { width: 60%; height: 60%; top: 20% !important; left: 20% !important; min-width: 400px; min-height: 400px; } .wrapper .container .one .content, .wrapper .container .two .content, .wrapper .container .three .content, .wrapper .container .circle .content, .wrapper .container .p404 .content { width: 600px; height: 600px; display: flex; justify-content: center; align-items: center; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); animation: content 0.8s cubic-bezier(1, 0.06, 0.25, 1) backwards; } @keyframes content { 0% { width: 0; } } .wrapper .container .one .content .piece, .wrapper .container .two .content .piece, .wrapper .container .three .content .piece, .wrapper .container .circle .content .piece, .wrapper .container .p404 .content .piece { width: 200px; height: 80px; display: flex; position: absolute; border-radius: 80px; z-index: 1; animation: leftdir 8s cubic-bezier(1, 0.06, 0.25, 1) infinite both; } @keyframes leftdir { 50% { left: 80%; width: 10%; } } @keyframes rightdir { 50% { right: 80%; width: 10%; } } @media screen and (max-width: 799px) { .wrapper .container .one, .wrapper .container .two, .wrapper .container .three, .wrapper .container .circle, .wrapper .container .p404 { width: 90%; height: 90%; top: 5% !important; left: 5% !important; min-width: 280px; min-height: 280px; } } @media screen and (max-height: 660px) { .wrapper .container .one, .wrapper .container .two, .wrapper .container .three, .wrapper .container .circle, .wrapper .container .p404 { min-width: 280px; min-height: 280px; width: 60%; height: 60%; top: 20% !important; left: 20% !important; } } .wrapper .container .text { width: 60%; height: 40%; min-width: 400px; min-height: 500px; position: absolute; margin: 40px 0; animation: text 0.6s 1.8s ease backwards; } @keyframes text { 0% { opacity: 0; transform: translateY(40px); } } @media screen and (max-width: 799px) { .wrapper .container .text { min-height: 400px; height: 80%; } } .wrapper .container .text article { width: 400px; position: absolute; bottom: 0; z-index: 4; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; bottom: 0; left: 50%; transform: translateX(-50%); } @media screen and (max-width: 799px) { .wrapper .container .text article { width: 100%; } } .wrapper .container .text article p { color: white; font-size: 18px; letter-spacing: 0.6px; margin-bottom: 40px; text-shadow: 6px 6px 10px #32243E; } .wrapper .container .text article button { height: 40px; padding: 0 30px; border-radius: 50px; cursor: pointer; box-shadow: 0px 15px 20px rgba(54, 24, 79, 0.5); z-index: 3; color: #695681; background-color: white; text-transform: uppercase; font-weight: 600; font-size: 12px; transition: all 0.3s ease; } .wrapper .container .text article button:hover { box-shadow: 0px 10px 10px -10px rgba(54, 24, 79, 0.5); transform: translateY(5px); background: #212121; color: white; } .wrapper .container .p404 { font-size: 200px; font-weight: 700; letter-spacing: 4px; color: white; display: flex !important; justify-content: center; align-items: center; position: absolute; z-index: 2; animation: anime404 0.6s cubic-bezier(0.3, 0.8, 1, 1.05) both; animation-delay: 1.2s; } @media screen and (max-width: 799px) { .wrapper .container .p404 { font-size: 100px; } } @keyframes anime404 { 0% { opacity: 0; transform: scale(10) skew(20deg, 20deg); } } .wrapper .container .p404:nth-of-type(2) { color: #36184F; z-index: 1; animation-delay: 1s; filter: blur(10px); opacity: 0.8; } .wrapper .container .circle { position: absolute; } .wrapper .container .circle:before { content: ''; position: absolute; width: 800px; height: 800px; background-color: rgba(54, 24, 79, 0.2); border-radius: 100%; top: 50%; left: 50%; transform: translate(-50%, -50%); box-shadow: inset 5px 20px 40px rgba(54, 24, 79, 0.25), inset 5px 0px 5px rgba(50, 36, 62, 0.3), inset 5px 5px 20px rgba(50, 36, 62, 0.25), 2px 2px 5px rgba(255, 255, 255, 0.2); animation: circle 0.8s cubic-bezier(1, 0.06, 0.25, 1) backwards; } @keyframes circle { 0% { width: 0; height: 0; } } @media screen and (max-width: 799px) { .wrapper .container .circle:before { width: 400px; height: 400px; } } .wrapper .container .one .content:before { content: ''; position: absolute; width: 600px; height: 600px; background-color: rgba(54, 24, 79, 0.3); border-radius: 100%; box-shadow: inset 5px 20px 40px rgba(54, 24, 79, 0.25), inset 5px 0px 5px rgba(50, 36, 62, 0.3), inset 5px 5px 20px rgba(50, 36, 62, 0.25), 2px 2px 5px rgba(255, 255, 255, 0.2); animation: circle 0.8s 0.4s cubic-bezier(1, 0.06, 0.25, 1) backwards; } @media screen and (max-width: 799px) { .wrapper .container .one .content:before { width: 300px; height: 300px; } } .wrapper .container .one .content .piece { background: linear-gradient(90deg, #8077EA 13.7%, #EB73FF 94.65%); } .wrapper .container .one .content .piece:nth-child(1) { right: 15%; top: 18%; height: 30px; width: 120px; animation-delay: 0.5s; animation-name: rightdir; } .wrapper .container .one .content .piece:nth-child(2) { left: 15%; top: 45%; width: 150px; height: 50px; animation-delay: 1s; animation-name: leftdir; } .wrapper .container .one .content .piece:nth-child(3) { left: 10%; top: 75%; height: 20px; width: 70px; animation-delay: 1.5s; animation-name: leftdir; } .wrapper .container .two .content .piece { background: linear-gradient(90deg, #f79d00 0%, #64f38c 100%); } .wrapper .container .two .content .piece:nth-child(1) { left: 0%; top: 25%; height: 40px; width: 120px; animation-delay: 2s; animation-name: leftdir; } .wrapper .container .two .content .piece:nth-child(2) { right: 15%; top: 35%; width: 180px; height: 50px; animation-delay: 2.5s; animation-name: rightdir; } .wrapper .container .two .content .piece:nth-child(3) { right: 10%; top: 80%; height: 20px; width: 160px; animation-delay: 3s; animation-name: rightdir; } .wrapper .container .three .content .piece { background: linear-gradient(90deg, #3498db 0%, #2c3e50 100%); } .wrapper .container .three .content .piece:nth-child(1) { left: 25%; top: 35%; height: 20px; width: 80px; animation-name: leftdir; animation-delay: 3.5s; } .wrapper .container .three .content .piece:nth-child(2) { right: 10%; top: 55%; width: 140px; height: 40px; animation-name: rightdir; animation-delay: 4s; } .wrapper .container .three .content .piece:nth-child(3) { left: 40%; top: 68%; height: 20px; width: 80px; animation-name: leftdir; animation-delay: 4.5s; } |
function.js
The final step, create a JavaScript file named ‘function.js‘ and put the codes.
1 2 3 |
// Code By Webdevtrick ( https://webdevtrick.com ) var PRllax = document.getElementById('PRllax'); var parallax = new Parallax(PRllax); |
That’s It. Now you have successfully created Parallax Error 404 Page Animation With CSS & JS, Move On Hover. If you have any doubt or question comment down below.
Thanks For Visiting, Keep Visiting.