HTML, CSS, Javascript Codes
HTML, CSS, Javascript Codes
<!DOCTYPE html>
<html>
<head>
<title>Grocery Store </title>
<link rel="stylesheet"
href="https://unpkg.com/swiper@7/swiper-bundle.min.
css" />
<meta name="viewport"
content="width=device-width, initial-scale=1.0">
</head>
<body>
<!-- header section -->
<header class="header">
<a href="#" class="logo"> <i class="fa
fa-shopping-basket"></i> Grocery </a>
<nav class="navbar">
<a href="#Home">Home</a>
<a href="#Features">Features</a>
<a href="#Products">Products</a>
<a href="#Review">Review</a>
</nav>
<div class="icons">
<div class="fa fa-bars" id="menu-btn"></div>
<div class="fa fa-search"
id="search-btn"></div>
<div class="fa fa-shopping-cart"
id="cart-btn"></div>
<div class="fa fa-user" id="login-btn"></div>
</div>
<form class="search-form">
<input type="search" id="search-box"
placeholder="Search Here...">
<label for="search-box" class="fa
fa-search"></label>
</form>
<div class="shopping-cart">
<div class="box">
<i class="fa fa-trash"></i>
<img src="image/watermelon.jpg">
<div class="content">
<h3>watermelon</h3>
<span class="price">$5.99/-</span>
<span class="quantity">Qty : 1</span>
</div>
</div>
<div class="box">
<i class="fa fa-trash"></i>
<img src="image/onion.jpg">
<div class="content">
<h3>onion</h3>
<span class="price">$3.99/-</span>
<span class="quantity">Qty : 1</span>
</div>
</div>
<div class="box">
<i class="fa fa-trash"></i>
<img src="image/chicken">
<div class="content">
<h3>chicken</h3>
<span class="price">$7.99/-</span>
<span class="quantity">Qty : 1</span>
</div>
</div>
</div>
</form>
</header>
<!-- header section -->
<div class="box-container">
<div class="box">
<img src="image/feature img-1.jpg">
<h3>fresh and Organic</h3>
<a href="#" class="btn">read more</a>
</div>
<div class="box">
<img src="image/feature img-2">
<h3>free Delivery</h3>
<a href="#" class="btn">read more</a>
</div>
<div class="box">
<img src="image/feature img-3.jpg">
<h3>Easy payments</h3>
<a href="#" class="btn">read more</a>
</div>
</div>
</section>
<!-- our features section -->
</div>
</div>
<script
src="https://cdn.jsdelivr.net/npm/swiper@11/swiper-
bundle.min.js"></script>
<script src="js/script.js"></script>
</body>
</html>
JAVASCRIPT code:
let searchForm =
document.querySelector('.search-form');
document.querySelector('#search-btn').onclick = ()
=>
{
searchForm.classList.toggle('active');
shoppingCart.classList.remove('active');
loginForm.classList.remove('active');
navbar.classList.remove('active');
}
let shoppingCart =
document.querySelector('.shopping-cart');
document.querySelector('#cart-btn').onclick = () =>
{
searchForm.classList.remove('active');
shoppingCart.classList.toggle('active');
loginForm.classList.remove('active');
navbar.classList.remove('active');
}
let loginForm =
document.querySelector('.login-form');
document.querySelector('#login-btn').onclick = ()
=>
{
searchForm.classList.remove('active');
shoppingCart.classList.remove('active');
loginForm.classList.toggle('active');
navbar.classList.remove('active');
}
document.querySelector('#menu-btn').onclick = () =>
{
searchForm.classList.remove('active');
shoppingCart.classList.remove('active');
loginForm.classList.remove('active');
navbar.classList.toggle('active');
}
window.onscroll = () =>
{
searchForm.classList.remove('active');
shoppingCart.classList.remove('active');
loginForm.classList.remove('active');
navbar.classList.remove('active');
}
var swiper = new Swiper(".product-slider", {
loop: true,
spaceBetween: 20,
autoplay: {
delay: 7500,
disableOnInteraction: false,
},
breakpoints: {
0: {
slidesPerView: 1,
},
768: {
slidesPerView: 2,
},
1020: {
slidesPerView: 3,
},
},
});
autoplay: {
delay: 7500,
disableOnInteraction: false,
},
breakpoints: {
0: {
slidesPerView: 1,
},
768: {
slidesPerView: 2,
},
1020: {
slidesPerView: 3,
},
},
});
CSS code:
:root
{
--green: green;
--bLack: #130f40;
--Light-color: #666;
--box-shadow: 0 .5rem 1.5rem rgba(0,0,0.1);
--border: 2rem solid rgba(0,0,0.1);
--outLine: 1rem solid rgba (0,0,0.1);
}
*
{
font-family: 'Poppins', sans-serif;
margin: 0;
padding: 0;
box-sizing: border-box;
outline: none;
border: none;
text-decoration: none;
text-transform: capitalize;
transition: all .2s linear;
}
html
{
font-size: 62.5%;
overflow-x: hidden;
scroll-behavior: smooth;
scroll-padding-top:7rem;
}
body
{
background: #eee;
}
.heading
{
text-align: center;
padding: 2rem 0;
padding-bottom: 3rem;
font-size: 3.5rem;
color: var(--bLack);
}
.heading span
{
background: var(--green);
color: #fff;
display: inline-block;
padding: .5rem 3rem;
clip-path: polygon(100% 0, 93% 50%, 100% 99%,
0% 100%, 7% 50%, 0% 0%);
}
.btn
{
border: .2rem solid var(--bLack);
margin-top: 1rem;
display: inline-block;
padding: .8rem 3rem;
font-size: 1.7rem;
border-radius: .5rem;
color: var(--bLack);
cursor: pointer;
background: none;
}
.btn:hover
{
background: var(--green);
color: #fff;
}
.header
{
border:2px solid;
position: fixed;
top: 0;
Left: 0;
right: 0;
display: flex;
align-items: center;
justify-content: space-between;
padding: 2rem 9%;
background: #fff;
box-shadow: var(--box-shadow);
}
.header .logo
{
font-size: 2.5rem;
font-weight: bolder;
}
.header .logo i
{
color: var(--green);
}
.header .navbar a
{
font-size: 1.7rem;
margin: 0 1rem;
color: var(--bLack);
}
#menu-btn
{
display: none;
}
.header .search-form
{
border: 1px solid;
position: absolute;
top: 110%;
right: -110%;
width: 50rem;
height: 5rem;
background: #fff;
border-radius: .5rem;
overflow: hidden;
display: flex;
align-items: center;
box-shadow: var (--box-shadow);
}
.header .search-form.active
{
right: 2rem;
transition: .4s linear;
}
.header .shopping-cart
{
border: 0px solid;
position: absolute;
top: 110%;
right: -110%;
padding: 1rem;
border-radius: .5rem;
box-shadow: var (--box-shadow);
width: 50rem;
background: #fff;
}
.header .login-form
{
border: 0px solid;
position: absolute;
width: 35rem;
top: 110%;
right: -110%;
box-shadow: var(--box-shadow);
padding: 2rem;
border-radius: 5rem;
background: #fff;
text-align: center;
}
.header .login-form.active
{
right: 2rem;
transition: .4s linear;
}
.header .login-form h3
{
font-size: 2.5rem;
text-transform: uppercase;
color: var(--bLack);
}
.header .login-form p
{
font-size: 1.4rem;
padding: .5rem 0;
color: var(--Light-color);
}
.header .login-form p a
{
color: var(--green);
text-decoration: underline;
}
.home
{
border: 0px solid;
display: flex;
justify-content: center;
background: url(../image/banner-img.jpg)
no-repeat;
background-position: center;
background-size: cover;
padding-top: 17rem;
padding-bottom: 10rem;
}
.home .content
{
border: 0px solid;
text-align: center;
width: 60rem;
}
.home .content h3
{
color: var(--bLack);
font-size: 3rem;
}
.home .content p
{
color: var(--Light-color);
font-size: 1.7rem;
padding: 1rem 0;
line-height: 1.8;
}
/*features*/
.features .box-container
{
border: 0px solid;
display: grid;
grid-template-columns: repeat(auto-fit,
minmax(30rem, 1fr));
gap: 1.5rem;
}
/*features*/
/*products*/
.products .product-slider
{
border: 0px solid;
padding: 1rem;
}
.products .product-slider:first-child
{
margin-bottom: 2rem;
}
.products .product-slider .box
{
border: 0px solid red;
background: #fff;
border-radius: .5rem;
text-aLign: center;
padding: 3rem 2rem;
outLine-offset: -1rem;
outline: var(--outline);
box-shadow: var(--box-shadow);
transition: .2s linear;
}
/*review*/
.review .review-slider+
{
border: 0px solid;
padding: 1rem;
}
/*review*/
/* media queries */
@media (max-width: 991px)
{
html
{
font-size: 55%;
}
.header
{
padding: 2rem;
}
section
{
padding: 2rem;
}
}
.header .search-form
{
width: 90%;
}
.header .navbar
{
position: absolute;
top: 110%;
right: -110%;
width: 30rem;
box-shadow: var(--box-shadow);
border-radius: .5rem;
background: #fff;
}
.header .navbar a
{
font-size: 2rem;
margin: 2rem 2.5rem;
display: block;
}
}
.heading
{
font-size: 2.5rem;
}
}
rl(
'https://fonts.googleapis.com/css2?family=Poppins:
ital,wght@0,400;0,500;1, 300&display=swap');
:root
{
--green: green;
--bLack: #130f40;
--Light-color: #666;
--box-shadow: 0 .5rem 1.5rem rgba(0,0,0.1);
--border: 2rem solid rgba(0,0,0.1);
--outLine: 1rem solid rgba (0,0,0.1);
}
*
{
font-family: 'Poppins', sans-serif;
margin: 0;
padding: 0;
box-sizing: border-box;
outline: none;
border: none;
text-decoration: none;
text-transform: capitalize;
transition: all .2s linear;
}
html
{
font-size: 62.5%;
overflow-x: hidden;
scroll-behavior: smooth;
scroll-padding-top:7rem;
}
body
{
background: #eee;
}
.heading
{
text-align: center;
padding: 2rem 0;
padding-bottom: 3rem;
font-size: 3.5rem;
color: var(--bLack);
}
.heading span
{
background: var(--green);
color: #fff;
display: inline-block;
padding: .5rem 3rem;
clip-path: polygon(100% 0, 93% 50%, 100% 99%,
0% 100%, 7% 50%, 0% 0%);
}
.btn
{
border: .2rem solid var(--bLack);
margin-top: 1rem;
display: inline-block;
padding: .8rem 3rem;
font-size: 1.7rem;
border-radius: .5rem;
color: var(--bLack);
cursor: pointer;
background: none;
}
.btn:hover
{
background: var(--green);
color: #fff;
}
.header
{
border:2px solid;
position: fixed;
top: 0;
Left: 0;
right: 0;
display: flex;
align-items: center;
justify-content: space-between;
padding: 2rem 9%;
background: #fff;
box-shadow: var(--box-shadow);
}
.header .logo
{
font-size: 2.5rem;
font-weight: bolder;
}
.header .logo i
{
color: var(--green);
}
.header .navbar a
{
font-size: 1.7rem;
margin: 0 1rem;
color: var(--bLack);
}
#menu-btn
{
display: none;
}
.header .search-form
{
border: 1px solid;
position: absolute;
top: 110%;
right: -110%;
width: 50rem;
height: 5rem;
background: #fff;
border-radius: .5rem;
overflow: hidden;
display: flex;
align-items: center;
box-shadow: var (--box-shadow);
}
.header .search-form.active
{
right: 2rem;
transition: .4s linear;
}
.header .shopping-cart
{
border: 0px solid;
position: absolute;
top: 110%;
right: -110%;
padding: 1rem;
border-radius: .5rem;
box-shadow: var (--box-shadow);
width: 50rem;
background: #fff;
}
.header .login-form
{
border: 0px solid;
position: absolute;
width: 35rem;
top: 110%;
right: -110%;
box-shadow: var(--box-shadow);
padding: 2rem;
border-radius: 5rem;
background: #fff;
text-align: center;
}
.header .login-form.active
{
right: 2rem;
transition: .4s linear;
}
.header .login-form h3
{
font-size: 2.5rem;
text-transform: uppercase;
color: var(--bLack);
}
.header .login-form p
{
font-size: 1.4rem;
padding: .5rem 0;
color: var(--Light-color);
}
.header .login-form p a
{
color: var(--green);
text-decoration: underline;
}
.home
{
border: 0px solid;
display: flex;
justify-content: center;
background: url(../image/banner-img.jpg)
no-repeat;
background-position: center;
background-size: cover;
padding-top: 17rem;
padding-bottom: 10rem;
}
.home .content
{
border: 0px solid;
text-align: center;
width: 60rem;
}
.home .content h3
{
color: var(--bLack);
font-size: 3rem;
}
.home .content p
{
color: var(--Light-color);
font-size: 1.7rem;
padding: 1rem 0;
line-height: 1.8;
}
/*features*/
.features .box-container
{
border: 0px solid;
display: grid;
grid-template-columns: repeat(auto-fit,
minmax(30rem, 1fr));
gap: 1.5rem;
}
/*features*/
/*products*/
.products .product-slider
{
border: 0px solid;
padding: 1rem;
}
.products .product-slider:first-child
{
margin-bottom: 2rem;
}
.products .product-slider .box
{
border: 0px solid red;
background: #fff;
border-radius: .5rem;
text-aLign: center;
padding: 3rem 2rem;
outLine-offset: -1rem;
outline: var(--outline);
box-shadow: var(--box-shadow);
transition: .2s linear;
}
/*review*/
.review .review-slider+
{
border: 0px solid;
padding: 1rem;
}
/*review*/
/* media queries */
@media (max-width: 991px)
{
html
{
font-size: 55%;
}
.header
{
padding: 2rem;
}
section
{
padding: 2rem;
}
}
.header .search-form
{
width: 90%;
}
.header .navbar
{
position: absolute;
top: 110%;
right: -110%;
width: 30rem;
box-shadow: var(--box-shadow);
border-radius: .5rem;
background: #fff;
}
.header .navbar a
{
font-size: 2rem;
margin: 2rem 2.5rem;
display: block;
}
}
.heading
{
font-size: 2.5rem;
}
}