In this post, we will learn how to create a landing page for your website. It has a logo, menu, and one hero section image which identifies the niche of the website. In the last, we have learned how to create a CSS box-shadow | CSS shadow image. Today our topic is to create a beautiful landing page for a website using HTML, CSS, and javascript languages.
Landing page in HTML, CSS, and javascript:
As you know that landing pages represents the company and we have created it for our company. It has a logo on the left top side. Then it has a menu on the right top side of the landing page.
Below the hero section, we have an image with its description in a box and they are aligned using the CSS flex property. Then we have a gallery of the website products. In the gallery, you can use the images related to your niche on your landing page and it helps the visitors to choose your services wisely.
Therefore, we have different logos of the companies and you can select the products related to that specific company. Emails newsletter is also used there and you can ask your visitors to subscribe to your landing page. Whenever you will post any new thing you can send an email to your subscribers.
You might like it:
In the end, we have a footer on the landing page. There must be a footer for the landing page and website. So, it has some direct links and address details with contact details as well. Let us know how to create using these three languages for our landing page.
How do create a Landing page in HTML, CSS, and javascript?
We will create it in four basic steps and you have to follow them if you want to create this type of landing page.
Download a code editor for the landing page:
Code editor provides an environment for writing the code easily. VS code is used for writing the code of HTML, CSS, and javascript. You can use any code editor for yourself but it has a lot of advantages for using it.
Source code of Html:
It is a markup language and we used it to create the skeleton for our landing page. The HTML code is available for this page. Copy this code and create a file of Html and then paste it there into an HTML file.
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 |
<html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title> Landing Page | FantacyDesigns</title> <link rel="stylesheet" href="style.css"> </head> <body> <link href='https://unpkg.com/boxicons@2.0.7/css/boxicons.min.css' rel='stylesheet'> <body> <header> <div class="company-logo">Z-Lapss.</div> <nav class="navbar"> <ul class="nav-items"> <li class="nav-item"><a href="#" class="nav-link">HOME</a></li> <li class="nav-item"><a href="#" class="nav-link">OFFER</a></li> <li class="nav-item"><a href="#" class="nav-link">SHOP</a></li> <li class="nav-item"><a href="#" class="nav-link">CONTACT</a></li> </ul> </nav> <div class="menu-toggle"> <i class="bx bx-menu"></i> <i class="bx bx-x"></i> </div> </header> <main> <!-- HOME SECTION --> <section class="container section-1"> <div class="slogan"> <h1 class="company-title">DOWNTOWN TECH </h1> <h2 class="company-slogan"> The biggest computer shop in the area where customers comes first. </h2> </div> <div class="home-computer-container"> <img class="home-computer" src="https://github.com/r-e-d-ant/Computer-store-website/blob/main/assets/images/home_img.png?raw=true" alt="a computer in dark with shadow" class="home-img"> </div> </section> <!-- OFFER SECTION --> <section class="container section-2"> <!-- offer 1 --> <div class="offer offer-1"> <img src="https://github.com/r-e-d-ant/Computer-store-website/blob/main/assets/images/offer_1.png?raw=true" alt="a computer in dark with with white shadow" class="offer-img offer-1-img"> <div class="offer-description offer-desc-1"> <h2 class="offer-title">Macbook pro</h2> <p class="offer-hook">This a Macbook pro nulla vulputate magna vel odio sagittis bibendium...</p> <div class="cart-btn">ADD TO CART</div> </div> </div> <!-- offer 2 --> <div class="offer offer-2"> <img src="https://github.com/r-e-d-ant/Computer-store-website/blob/main/assets/images/offer_2.png?raw=true" alt="a opened computer" class="offer-img offer-2-img"> <div class="offer-description offer-desc-2"> <h2 class="offer-title">Lenovo</h2> <p class="offer-hook">This a Lenovo nulla vulputate magna vel odio sagittis bibendium...</p> <div class="cart-btn">ADD TO CART</div> </div> </div> </section> <!-- PRODUCT SECTION --> <section class="container section-3"> <!-- product - 1 --> <div class="product product-1"> <img src="https://github.com/r-e-d-ant/Computer-store-website/blob/main/assets/images/comp_1.png?raw=true" alt="computer to sell" class="product-img"> <span class="product_add_cart">ADD TO CART</span> </div> <!-- product - 2 --> <div class="product product-2"> <img src="https://github.com/r-e-d-ant/Computer-store-website/blob/main/assets/images/comp_2.png?raw=true" alt="computer to sell" class="product-img"> <span class="product_add_cart">ADD TO CART</span> </div> <!-- product - 3 --> <div class="product product-3"> <img src="https://github.com/r-e-d-ant/Computer-store-website/blob/main/assets/images/comp_3.png?raw=true" alt="computer to sell" class="product-img"> <span class="product_add_cart">ADD TO CART</span> </div> <!-- product - 4 --> <div class="product product-4"> <img src="https://github.com/r-e-d-ant/Computer-store-website/blob/main/assets/images/comp_4.png?raw=true" alt="computer to sell" class="product-img"> <span class="product_add_cart">ADD TO CART</span> </div> </section> <!-- SPONSOR SECTION --> <section class="container section-4"> <!-- SPONSOR group 1 --> <div class="sponsor sponsor-1"><img src="https://raw.githubusercontent.com/r-e-d-ant/Computer-store-website/b90ac65459206fef22e9b87313f587185554263b/assets/images/microsoft.svg" alt=""></div> <div class="sponsor sponsor-2"><img src="https://raw.githubusercontent.com/r-e-d-ant/Computer-store-website/b90ac65459206fef22e9b87313f587185554263b/assets/images/apple.svg" alt=""></div> <!-- SPONSOR group 2 --> <div class="sponsor sponsor-3"><img src="https://raw.githubusercontent.com/r-e-d-ant/Computer-store-website/b90ac65459206fef22e9b87313f587185554263b/assets/images/dell.svg" alt=""></div> <div class="sponsor sponsor-4"><img src="https://raw.githubusercontent.com/r-e-d-ant/Computer-store-website/b90ac65459206fef22e9b87313f587185554263b/assets/images/ibm.svg" alt=""></div> </section> <!-- SUBSCRIBE SECTION--> <section class="container section-5"> <h2 class="subscribe-input-label">NEWSLETTER</h2> <div class="subscribe-container"> <input type="text" id="email-subscribe" placeholder="Email address..."> <input type="submit" value="SUBSCRIBE"> </div> </section> </main> <footer> <div class="container top-footer"> <!-- footer item 1 --> <div class="footer-item"> <h2 class="footer-title">Z-Lapss.</h2> <div class="footer-items"> <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p> </div> </div> <!-- footer item 2 --> <div class="footer-item"> <h2 class="footer-title">SERVICES</h2> <div class="footer-items"> <h3>Dummy-link</h3> <h3>Dummy-link</h3> <h3>Dummy-link</h3> <h3>Dummy-link</h3> <h3>Dummy-link</h3> </div> </div> <!-- footer item 3 --> <div class="footer-item"> <h2 class="footer-title">SUPPLIERS</h2> <div class="footer-items"> <h3>Dummy-text</h3> <h3>Dummy-text</h3> <h3>Dummy-text</h3> <h3>Dummy-text</h3> <h3>Dummy-text</h3> </div> </div> <!-- footer item 4 --> <div class="footer-item"> <h2 class="footer-title">INVESTMENT</h2> <div class="footer-items"> <h3>Dummy-text</h3> <h3>Dummy-text</h3> <h3>Dummy-text</h3> <h3>Dummy-text</h3> <h3>Dummy-text</h3> </div> </div> </div> <div class="container end-footer"> <div class="copyright">copyright © 2022 - Present • <b>FantacyDesigns</b></div> <a class="designer" href="#"> - JD</a> </div> </footer> </body> </body> </html> |
Source code of CSS:
CSS is a markup language and it is mostly used to design the landing pages. We have also designed our page using CSS. Therefore, the code is given below. Just copy this code and create a new file for css and paste this code into your css file.
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 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 |
@import url("https://fonts.googleapis.com/css2?family=Raleway:wght@100;200;300;400"); *, *::before, *::after { padding: 0; margin: 0; box-sizing: border-box; } /* ================= VARIABLE ================ */ :root { --primary-color: hsl(9, 94%, 61%); --primary-color-alt: hsl(28, 72%, 83%); --second-color: #3e537c; --second-color-alt: hsla(220, 33%, 36%, 65%); --third-color: hsl(220, 36%, 28%); --white-color: #fbfbfb; --white-color-alt: hsl(12, 14%, 93%); --dark-color: hsl(300, 100%, 0%); } /* ================= BASE ==================== */ li { list-style: none; } a { text-decoration: none; } img { width: 100%; height: auto; } .bx { font-size: 2.5rem; } .container { padding: 0 2rem; } /* -- BODY -- */ body { font-family: "Raleway", sans-serif; font-size: 1rem; background-color: var(--white-color); } /* ================= HEADER ================ */ header { display: flex; align-items: center; justify-content: space-between; background-color: var(--dark-color); padding: 1rem 2rem; } .company-logo { font-size: 2.5rem; background: -webkit-linear-gradient( 120deg, var(--primary-color-alt), var(--primary-color) ); -webkit-background-clip: text; -webkit-text-fill-color: transparent; } .nav-items { display: flex; } .nav-item { margin: 0 2rem; } .nav-link { font-size: 1.1rem; letter-spacing: 0.05rem; position: relative; background: -webkit-linear-gradient( var(--primary-color-alt), var(--primary-color) ); -webkit-background-clip: text; -webkit-text-fill-color: transparent; } .nav-link::before { content: ""; background: linear-gradient(var(--primary-color), var(--primary-color-alt)); width: 100%; height: 0.05rem; position: absolute; left: 0; bottom: 0; transform: scaleX(0); transform-origin: bottom right; transition: transform 150ms; } .nav-link:hover::before { transform: scaleX(1); transform-origin: bottom left; } .menu-toggle { display: none; } .bx-menu, .bx-x { cursor: pointer; background: -webkit-linear-gradient( 120deg, var(--primary-color-alt), var(--primary-color) ); -webkit-background-clip: text; -webkit-text-fill-color: transparent; display: none !important; } /* ================= MAIN ================ */ /* -------- HOME SECTION -------------- */ .section-1 { height: 100vh; background-color: var(--dark-color); display: grid; } /* .home-computer-container {} */ .slogan .company-title { background: -webkit-linear-gradient( 120deg, var(--primary-color-alt), var(--primary-color) ); -webkit-background-clip: text; -webkit-text-fill-color: transparent; margin-top: 2rem; font-size: 1.5rem; font-weight: 600; } .slogan .company-slogan { background: -webkit-linear-gradient( 120deg, var(--primary-color-alt), var(--primary-color) ); -webkit-background-clip: text; -webkit-text-fill-color: transparent; margin-top: 1rem; font-size: 1.2rem; font-weight: 400; line-height: 1.8rem; } /* -------- OFFER SECTION ------------- */ .section-2 { margin: 2rem 0; } .offer { background-color: var(--dark-color); margin: 1rem 0; display: grid; } .offer img { background-color: var(--dark-color); padding: 2rem 0; } .offer-1 img { background-color: var(--dark-color); padding: 3rem 0; } .offer-description { background-color: var(--white-color-alt); padding: 0 1rem; } .offer-description .offer-title { color: var(--second-color); font-size: 1.8rem; font-weight: 400; padding: 1.5rem 0 0.5rem 0; } .offer-description .offer-hook { color: var(--second-color-alt); font-size: 1.2rem; } .offer-description .cart-btn { cursor: pointer; color: var(--second-color-alt); font-size: 1.1rem; display: grid; place-items: center; margin: 2rem 0 1rem 0; width: 10rem; height: 3rem; background-image: linear-gradient( to top, var(--primary-color-alt), var(--primary-color) ); } .offer-description .cart-btn:hover { background-image: linear-gradient( to bottom, var(--primary-color-alt), var(--primary-color) ); } /* -------- PRODUCT SECTION ----------- */ .section-3 { display: grid; place-items: center; justify-content: space-around; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(200px, 400px)); } .product { cursor: pointer; background-color: var(--white-color-alt); position: relative; } .product::before { content: ""; background-image: linear-gradient( to bottom, hsla(29, 72%, 83%, 0.438), hsla(9, 94%, 61%, 0.507) ); position: absolute; top: 0; bottom: 0; left: 0; right: 0; } .product_add_cart { color: var(--white-color-alt); font-size: 1.2rem; background-color: hsl(9, 94%, 65%); padding: 1rem 0.4rem; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); transition: transform 300ms, color 300ms, box-shadow 300ms; } .product_add_cart:hover { color: var(--white-color); box-shadow: 0 1rem 0 -0.5rem hsl(17, 79%, 65%, 0.7), 0 2rem 0 -1rem hsla(17, 79%, 65%, 0.65); } /* -------- SPONSOR SECTION ----------- */ .section-4 { margin: 4rem 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-around; } .sponsor img { cursor: pointer; width: 40px; height: 40px; filter: grayscale(100%); opacity: 0.8; transition: opacity 300ms; } .sponsor img:hover { /* filter: grayscale(0); */ opacity: 1; } /* ========= SUBSCRIBE SECTION ========== */ .section-5 { display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 2rem 0; } .subscribe-input-label { margin-bottom: 1rem; font-size: 1.5rem; font-weight: 400; letter-spacing: 0.05rem; color: var(--second-color); } input[type="text"] { padding: 0 0.5rem; font-size: 1.1rem; width: 100%; height: 3rem; border: none; background-color: hsl(220, 33%, 90%); color: var(--second-color-alt); transition: background-color 300ms; } input[type="text"]:focus { outline: none; background-color: hsl(220, 33%, 95%); } input[type="text"]::placeholder { color: var(--second-color-alt); } input[type="submit"] { cursor: pointer; background-image: linear-gradient( to top, var(--primary-color-alt), var(--primary-color) ); color: var(--white-color-alt); margin: 1rem 0; border: none; width: 100%; height: 3rem; font-size: 1.2rem; transition: color 300ms; } input[type="submit"]:hover { background-image: linear-gradient( to bottom, var(--primary-color-alt), var(--primary-color) ); color: var(--white-color); } /* =============== FOOTER =============== */ .top-footer { background-color: var(--second-color); display: flex; flex-direction: column; } .footer-title { font-weight: 500; font-size: 1.2rem; padding: 1rem 0; background-image: -webkit-linear-gradient( 120deg, var(--primary-color-alt), var(--primary-color) ); background-clip: text; -webkit-background-clip: text; -webkit-text-fill-color: transparent; } .footer-items h3 { cursor: pointer; font-weight: 300; font-size: 1.1rem; padding: 0.1rem 0; width: 300px; color: var(--white-color-alt); } .footer-items p{ padding-right: 50px; color: #ddd; font-size: 14px; } .footer-items h3:hover { text-decoration: underline; } .footer-items h3:last-child { padding-bottom: 2rem; } .end-footer { display: flex; flex-direction: column; align-items: center; justify-content: center; background-color: var(--third-color); } .copyright { color: var(--white-color-alt); padding: 1rem 0; font-size: 0.9rem; } .copyright b { font-weight: inherit; font-size: 0.9rem; } .designer { color: hsla(0, 0%, 98%, 0.541); padding-bottom: 0.5rem; font-size: 0.9rem; } .designer:hover { text-decoration: underline; } /* =============== MEDIA QUERIES ======= */ @media screen and (max-width: 768px) { .container { padding: 0 1rem; } /* ================= HEADER ================ */ header { padding: 0.5rem 1rem; } .navbar { background-color: var(--dark-color); position: absolute; top: 3.5rem; right: 0; width: 100%; height: 100vh; display: flex; justify-content: center; transform: scaleY(0); transform-origin: bottom; transition: transform 500ms; } .show-navbar { display: flex; transform: scaleY(1); transform-origin: top; transition: transform 300ms; } .nav-items { display: flex; flex-direction: column; } .nav-item { margin: 0.5rem 0; } .menu-toggle { display: block; } .bx-menu { display: block !important; } .show-bx { display: block !important; } .hide-bx { display: none !important; } } @media (min-width: 769px) { header { padding: 1rem 5rem; } /* ================= MAIN ================ */ /* -------- HOME SECTION -------------- */ .section-1 { justify-content: space-between; grid-template-columns: 1fr 1fr; padding: 10rem 5rem 0 5rem; } .slogan .company-title { max-width: 30rem; font-size: 1.8rem; letter-spacing: 0.5rem; } .slogan .company-slogan { max-width: 20rem; font-size: 1.3rem; } /* -------- OFFER SECTION ------------- */ .section-2 { margin: 2rem 5rem; } .offer { margin: 5rem 0; align-items: center; justify-content: space-between; grid-template-rows: auto auto; } .offer-1 { grid-template-areas: "offer-1-img offer-desc-1"; } .offer-1 img { background-color: var(--dark-color); padding: 2rem 0; } .offer-2 { grid-template-areas: "offer-desc-2 offer-2-img"; } .offer-1-img { grid-area: offer-1-img; } .offer-2-img { grid-area: offer-2-img; } .offer-desc-1 { grid-area: offer-desc-1; } .offer-desc-2 { grid-area: offer-desc-2; } .offer-description .offer-title { font-size: 1.9rem; padding: 1.5rem 0 0.5rem 0; } .offer-description .offer-hook { max-width: 30rem; } .offer-description { background-color: var(--white-color-alt); padding: 2rem 1rem; } .offer-description .offer-title { padding: 0.5rem 0 1rem 0; } .offer-description .cart-btn { margin: 2rem 0 0.5rem 0; } /* -------- PRODUCT SECTION ----------- */ .section-3 { gap: 5rem; } .product::before { transform: scaleY(0); transform-origin: bottom; transition: transform 300ms; } .product:hover::before { transform: scaleY(1); transform-origin: top; transition: transform 300ms; } .product_add_cart { transform: scaleY(0); transform-origin: bottom; } .product:hover .product_add_cart { transform: translate(-50%, -50%) scaleY(1); transform-origin: top; } /* -------- SPONSOR SECTION ----------- */ .section-4 { margin: 5rem 0; } /* ========= SUBSCRIBE SECTION ========== */ .section-5 { padding: 1rem 0; } .section-5 .subscribe-container { display: flex; align-items: center; } input[type="text"] { padding: 0 1rem; width: 15rem; } input[type="submit"] { width: 10rem; } /* =============== FOOTER =============== */ .top-footer { flex-direction: row; justify-content: space-around; padding-bottom: 8rem; padding-top: 2rem; } .footer-title { font-size: 1rem; padding: 1rem 0; } .footer-items h3 { font-size: 0.9rem; } .end-footer { display: flex; flex-direction: column; align-items: center; justify-content: center; background-color: var(--third-color); } .copyright { color: hsla(0, 0%, 98%, 0.747); padding: 1rem 0; font-size: 0.8rem; } .copyright b { font-size: 0.7rem; } .designer { color: hsla(0, 0%, 98%, 0.322); font-size: 0.8rem; } } |
Source code of javascript:
Javascript is known as a dynamic programming language and we use it to add functionality to our website pages. Javascript code is given below. Create a javascript file and then copy this javascript code and paste it there in your javascript file.
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 |
<script> 'use strict' const menuToggle = document.querySelector('.menu-toggle'); const bxMenu = document.querySelector('.bx-menu'); const bxX = document.querySelector('.bx-x'); const navBar = document.querySelector('.navbar'); // --- open menu --- bxMenu.addEventListener('click', (e)=> { if(e.target.classList.contains('bx-menu')){ navBar.classList.add('show-navbar'); bxMenu.classList.add('hide-bx'); bxX.classList.add('show-bx'); } }) // --- close menu --- bxX.addEventListener('click', (e)=> { if(e.target.classList.contains('bx-x')){ navBar.classList.remove('show-navbar'); bxMenu.classList.remove('hide-bx'); bxX.classList.remove('show-bx'); } }) </script> |
Download source code:
Code was given but if you are still unable to create the landing page using the above source code then we have created a file. In this file, you will find all the necessary images and HTML, CSS, and javascript files. You just need to run the main file and your page will be there in front of you for free.
Task and Conclusion:
This landing page is divided into multiple sections and all the sections are different from each other. This page consists of different objects like images, text, buttons, headings, paragraphs, footer, icons, header, and hero sections. You need to modify this design and add new things. Change icons, text, images, and font family all over the page.
Download the source code from the below download source code button. If you have any type of query, feel free to ask in the comment section.
Thanks for reading this article.
Download Source CodeClick to Download