Solution: 3D Carousel Slider using HTML & CSS with source code, demo, and also how you can execute full program easily. To complete the program you need to follow those steps given bellow
Live Demo
Responsive Header Navigation Menu
3D Carousel Slider using HTML & CSS
Description
Back to coding, To complete this program with debugging free code you have to create two files. The first file is to HTML and the second file gonna be CSS for the style part,
index.html
Create an HTML file named ‘index.html‘ and put those 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 |
<!-- Coding Debugging (https://codingdebugging.com) --> <!DOCTYPE html> <html> <head> <title>3D Carousel Slider - Coding Debugging</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- My Stylesheet --> <link rel="stylesheet" href="style.css"> </head> <body> <input type="radio" name="position" checked /> <input type="radio" name="position" /> <input type="radio" name="position" /> <input type="radio" name="position" /> <input type="radio" name="position" /> <main id="carousel"> <div class="item"></div> <div class="item"></div> <div class="item"></div> <div class="item"></div> <div class="item"></div> <main> </body> </html> |
style.css
Create a CSS file named ‘style.css‘ and put those 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 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 |
body { height: 600px; margin: 0; display: grid; grid-template-rows: 500px 100px; grid-template-columns: 1fr 30px 30px 30px 30px 30px 1fr; align-items: center; justify-items: center; } main#carousel { grid-row: 1 / 2; grid-column: 1 / 8; width: 100vw; height: 500px; display: flex; align-items: center; justify-content: center; overflow: hidden; transform-style: preserve-3d; perspective: 600px; --items: 5; --middle: 3; --position: 1; pointer-events: none; } div.item { position: absolute; width: 300px; height: 400px; background-color: coral; --r: calc(var(--position) - var(--offset)); --abs: max(calc(var(--r) * -1), var(--r)); transition: all 0.25s linear; transform: rotateY(calc(-10deg * var(--r))) translateX(calc(-300px * var(--r))); z-index: calc((var(--position) - var(--abs))); } div.item:nth-of-type(1) { --offset: 1; background-color: #90f1ef; } div.item:nth-of-type(2) { --offset: 2; background-color: #ff70a6; } div.item:nth-of-type(3) { --offset: 3; background-color: #ff9770; } div.item:nth-of-type(4) { --offset: 4; background-color: #ffd670; } div.item:nth-of-type(5) { --offset: 5; background-color: #e9ff70; } input:nth-of-type(1) { grid-column: 2 / 3; grid-row: 2 / 3; } input:nth-of-type(1):checked ~ main#carousel { --position: 1; } input:nth-of-type(2) { grid-column: 3 / 4; grid-row: 2 / 3; } input:nth-of-type(2):checked ~ main#carousel { --position: 2; } input:nth-of-type(3) { grid-column: 4 /5; grid-row: 2 / 3; } input:nth-of-type(3):checked ~ main#carousel { --position: 3; } input:nth-of-type(4) { grid-column: 5 / 6; grid-row: 2 / 3; } input:nth-of-type(4):checked ~ main#carousel { --position: 4; } input:nth-of-type(5) { grid-column: 6 / 7; grid-row: 2 / 3; } input:nth-of-type(5):checked ~ main#carousel { --position: 5; } |
Thank you for visiting!
We appreciate you for your precious time. I hope you are learn something from here! If you have any queries about this coding comment down below we will reply ASAP.
Keep coding, Keep debugging!