Creating a Full-Width CSS Slider with Mega Menu Integration

Follow on LinkedIn

In this tutorial, we’ll build a sleek, full-width CSS slider positioned at the top of the page, perfect for highlighting featured content. We’ll also integrate a responsive mega menu, offering easy navigation and a polished user experience. Follow along as we combine HTML, CSS, and a touch of JavaScript to create this stylish and functional web layout.

<header>
	<div class="logo"></div>
	<div class="nav">
	  <ul>
		<li id="show-nails">
		  <a href="">Celebrities</a>
		  <div class="thumbnail-peekaboo">
					<img class="thumb" title="Hello everyoone" src="https://images.unsplash.com/photo-1700529043649-a04da2914062?q=80&w=2071&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D">
					<img class="thumb" src="https://images.unsplash.com/photo-1641893588018-b958a5845cab?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D">
					  <img class="thumb" src="https://images.unsplash.com/photo-1655948548273-d68bbf73ded8?q=80&w=2071&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D">
					<img class="thumb" src="https://plus.unsplash.com/premium_photo-1661890560407-ec98856efdd2?q=80&w=2046&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D">
					<img class="thumb" src="https://plus.unsplash.com/premium_photo-1683141079772-acf46d5e2ebb?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D">
					<img class="thumb" src="https://images.unsplash.com/photo-1685016989172-ccd033d2a94c?q=80&w=1804&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D">
		  </div>
		</li>
		
	  </ul>
	</div>
  </header>
  <div class="slider">
	<ul>
	  <li id="no-js-slider-1" class="slide">
		<img src="https://images.unsplash.com/photo-1700529043649-a04da2914062?q=80&w=2071&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D">
		<a class="prev" href="#no-js-slider-10">prev</a>
		<a class="next" href="#no-js-slider-2">next</a>
	  </li>
	  <li id="no-js-slider-2" class="slide">
		<img src="https://images.unsplash.com/photo-1641893588018-b958a5845cab?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D">
		<a class="prev" href="#no-js-slider-1">prev</a>
		<a class="next" href="#no-js-slider-3">next</a>           
	  </li>
	  <li id="no-js-slider-3" class="slide">
		<img src="https://images.unsplash.com/photo-1655948548273-d68bbf73ded8?q=80&w=2071&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D">
		<a class="prev" href="#no-js-slider-2">prev</a>
		<a class="next" href="#no-js-slider-4">next</a>           
	  </li>
	  <li id="no-js-slider-4" class="slide">
		<img src="https://plus.unsplash.com/premium_photo-1661890560407-ec98856efdd2?q=80&w=2046&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D">
		<a class="prev" href="#no-js-slider-3">prev</a>
		<a class="next" href="#no-js-slider-5">next</a>          
	  </li>
	  <li id="no-js-slider-5" class="slide">
		<img src="https://plus.unsplash.com/premium_photo-1683141079772-acf46d5e2ebb?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"> 
		<a class="prev" href="#no-js-slider-4">prev</a> 
		<a class="next" href="#no-js-slider-6">next</a>
	  </li>
	  <li id="no-js-slider-6" class="slide">
		<img src="https://images.unsplash.com/photo-1685016989172-ccd033d2a94c?q=80&w=1804&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"> 
		<a class="prev" href="#no-js-slider-5">prev</a> 
		<a class="next" href="#no-js-slider-7">next</a>
	  </li>
	</ul>
  </div>
  <style>
	* {
margin: 0;
padding: 0;
list-style-type:none;
}
header {
	height:40px;
	width:100%;
	position:fixed;
	background:rgba(0,0,0,0.9);
	z-index:120;
}
header li {
	float: left;
	list-style-type:none;
	border-right: 1px solid #252525;
}
header li a {
	float: left;
	width: 98px;
	height: 12px;
	padding: 14px 7px;
	color: #fff;
	text-decoration: none;
	text-align: center;
	text-transform: uppercase;
	font-weight: 700;
	letter-spacing: 1px;
	font: normal 62.5% "proxima-nova-alt", Helvetica, Arial, sans-serif;
}
header .logo {
	float: left;
	width: 201px;
	height: 40px;
	background:#fde624 url('https://lh4.googleusercontent.com/-JN1IZLtuToI/UUoZnMG3C_I/AAAAAAAAAE8/SEbJ9nqXGnY/s226/sprite.png') no-repeat 16px 1px;
}
#show-nails:hover div.thumbnail-peekaboo {
	display:block;
}
header div.thumbnail-peekaboo {
	display:none;
	height:165px;
	width:3000px;
	top:40px;
	left:0;
	background:#222;
	background-size:100px 100px;
	position:absolute;
}
/*header div.thumbnail-peekaboo:hover {
	-webkit-animation: TMNT 4s ease-in;
	-webkit-animation-fill-mode:backwards;
}*/
.thumb {
	height:140px;
	width:210px;
	top:136px;
	left:12px;
	position:relative;
	background-size:contain;
	box-shadow:-12px 0 0 12px #000;
}
.thumb:last-of-type {
  box-shadow:0 0 0 12px #000;
}
.thumb:after {
  content:attr(title);
  font:normal normal 20pt 'impact';
  position:relative;
}
.thumb:hover {
	-webkit-filter: grayscale(80%);
	-moz-filter: grayscale(80%);
	-ms-filter: grayscale(80%);
	-o-filter: grayscale(80%);
	filter: grayscale(80%);
	filter: url(grayscale.svg#greyscale);
	filter: gray;
}
@-webkit-keyframes TMNT {
	0%  { left: 0px; }
	100% { left: -1200px; }
}
a.prev,a.next {
	height:91px;
	position:absolute;
	width:43px;
	top:50%;
	margin-top:-30px;
	opacity:0.6;
	text-indent:-99999px;
	cursor:pointer;
	-webkit-transition:opacity 200ms ease-out;
}
a.prev:hover,a.next:hover {
	opacity:1;
}
.prev {
	left:0;
	background: #000 url('https://lh4.googleusercontent.com/-JN1IZLtuToI/UUoZnMG3C_I/AAAAAAAAAE8/SEbJ9nqXGnY/s226/sprite.png') no-repeat -200px 25px;
}
.next {
	right:0;
	background: #000 url('https://lh4.googleusercontent.com/-JN1IZLtuToI/UUoZnMG3C_I/AAAAAAAAAE8/SEbJ9nqXGnY/s226/sprite.png') no-repeat -167px 25px;
}
.slider {
	height:100vh;
	position: relative;
}
.slide {
	position:absolute;
	height:100%;
	width:100%;
}
.slider .slide:target {
	z-index: 100;
}
img {
	max-width:100%;
	width:100%;
	position:fixed;
	left:0;
}
  </style>

Credit: https://codepen.io/johnmotyljr/pen/kWwBOw

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

×