Create Responsive Food/Restaurant Website Using HTML CSS And JavaScript

 


HTML Code

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Responsive Food Website</title>
    <!-- Link To CSS -->
    <link rel="stylesheet" href="style.css">
    <!-- Box Icons -->
    <link rel="stylesheet"
  href="https://cdn.jsdelivr.net/npm/boxicons@latest/css/boxicons.min.css">
</head>
<body>
<!-- Navbar -->
<header>
    <a href="#" class="logo"><img src="img/logo.png" alt="">Foodie</a>
    <div class="bx bx-menu" id="menu-icon"></div>

    <ul class="navbar">
        <li><a href="#home">Home</a></li>
        <li><a href="#about">About</a></li>
        <li><a href="#shop">Shop</a></li>
        <li><a href="#customer">Customer</a></li>
        <li><a href="#contact">Contact</a></li>
    </ul>
</header>
<!-- Home -->
<section class="home" id="home">
    <div class="home-text">
        <span>Welcome To Our</span>
        <h1>Healthy Food <br>Collection!</h1>
        <p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Deleniti ullam velit consectetur vel, cumque quaerat?</p>
        <a href="#" class="btn">Our Menu</a>
    </div>
    <div class="home-img">
        <img src="img/salad.png" alt="">
    </div>
</section>
<!-- About -->
<section class="about" id="about">
    <h1>Today Deal's</h1>

    <div class="about-container">
        <!-- Box 1 -->
        <div class="about-box">
            <div class="box-img">
                <img src="img/about1.png" alt="">
            </div>
            <h3>Green Salad</h3>
            <h2>$ 12.4</h2>
        </div>
        <!-- Box 2 -->
        <div class="about-box">
            <div class="box-img">
                <img src="img/about2.png" alt="">
            </div>
            <h3>Green Salad</h3>
            <h2>$ 12.4</h2>
        </div>
        <!-- Box 3 -->
        <div class="about-box">
            <div class="box-img">
                <img src="img/about3.png" alt="">
            </div>
            <h3>Green Salad</h3>
            <h2>$ 12.4</h2>
        </div>
        <!-- Box 4 -->
        <div class="about-box">
            <div class="box-img">
                <img src="img/about4.png" alt="">
            </div>
            <h3>Green Salad</h3>
            <h2>$ 12.4</h2>
        </div>
    </div>
</section>
<!-- Shop -->
<section class="shop" id="shop">
    <div class="heading">
        <h2>Food Shop</h2>
        <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Obcaecati, cupiditate.</p>
    </div>
    <div class="shop-container">
        <div class="shop-box">
            <div class="shop-img">
                <img src="img/shop1.jpg" alt="">
            </div>
            <h3>Tasty Food</h3>
            <h2>$ 14.2</h2>
            <i class='bx bxs-cart-add'></i>
        </div>

        <div class="shop-box">
            <div class="shop-img">
                <img src="img/shop2.jpg" alt="">
            </div>
            <h3>Tasty Food</h3>
            <h2>$ 14.2</h2>
            <i class='bx bxs-cart-add'></i>
        </div>

        <div class="shop-box">
            <div class="shop-img">
                <img src="img/shop3.jpg" alt="">
            </div>
            <h3>Tasty Food</h3>
            <h2>$ 14.2</h2>
            <i class='bx bxs-cart-add'></i>
        </div>

        <div class="shop-box">
            <div class="shop-img">
                <img src="img/shop4.jpg" alt="">
            </div>
            <h3>Tasty Food</h3>
            <h2>$ 14.2</h2>
            <i class='bx bxs-cart-add'></i>
        </div>

        <div class="shop-box">
            <div class="shop-img">
                <img src="img/shop5.jpg" alt="">
            </div>
            <h3>Tasty Food</h3>
            <h2>$ 14.2</h2>
            <i class='bx bxs-cart-add'></i>
        </div>

        <div class="shop-box">
            <div class="shop-img">
                <img src="img/shop6.jpg" alt="">
            </div>
            <h3>Tasty Food</h3>
            <h2>$ 14.2</h2>
            <i class='bx bxs-cart-add'></i>
        </div>
    </div>
</section>
<section class="customer" id="customer">
    <div class="heading">
        <h2>Our Customer's</h2>
        <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Obcaecati, cupiditate.</p>
    </div>
    <div class="customer-container">
        <div class="box">
            <img src="img/c1.jpg" alt="">
            <div class="stars">
                <i class='bx bxs-star' ></i>
                <i class='bx bxs-star' ></i>
                <i class='bx bxs-star' ></i>
                <i class='bx bxs-star' ></i>
                <i class='bx bxs-star-half' ></i>
            </div>
            <p>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Fugiat, vero inventore ut voluptatum sit minus.</p>
            <h2>Tayler Swift</h2>
        </div>

        <div class="box">
            <img src="img/c2.jpg" alt="">
            <div class="stars">
                <i class='bx bxs-star' ></i>
                <i class='bx bxs-star' ></i>
                <i class='bx bxs-star' ></i>
                <i class='bx bxs-star' ></i>
                <i class='bx bxs-star-half' ></i>
            </div>
            <p>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Fugiat, vero inventore ut voluptatum sit minus.</p>
            <h2>Zayn Malik</h2>
        </div>

        <div class="box">
            <img src="img/c3.jpg" alt="">
            <div class="stars">
                <i class='bx bxs-star' ></i>
                <i class='bx bxs-star' ></i>
                <i class='bx bxs-star' ></i>
                <i class='bx bxs-star' ></i>
                <i class='bx bxs-star-half' ></i>
            </div>
            <p>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Fugiat, vero inventore ut voluptatum sit minus.</p>
            <h2>Ketty Perry</h2>
        </div>
    </div>
</section>
<section class="contact" id="contact">
    <div class="heading">
        <h2>Contact Us</h2>
        <p>Lorem ipsum dolor sit amet consectetur itate.</p>
    </div>
    <div class="contact-container">
        <div class="contact-info">
            <h2>Get In Touch</h2>
            <p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Laborum officiis nihil recusandae fugiat quas nisi.</p>
            <div class="adress">
                <i class='bx bxs-map' ><span>44 Street NYC, USA 10001</span></i>
                <i class='bx bxs-phone' ><span>+1 100 104 40001</span></i>
                <i class='bx bxs-envelope' ><span>contact@foodie.com</span></i>
            </div>
            <div class="social">
                <a href="#"><i class='bx bxl-facebook' ></i></a>
                <a href="#"><i class='bx bxl-twitter' ></i></a>
                <a href="#"><i class='bx bxl-instagram' ></i></a>
            </div>
        </div>

        <div class="contact-form">
            <form action="">
                <input type="text" placeholder="Name*">
                <input type="email" name="" id="" placeholder="Email*">
                <textarea name="" id="" cols="30" rows="10" placeholder="Message*"></textarea>
                <input type="button" value="Submit" class="btn">
            </form>
        </div>
    </div>

</section>
<!-- Copyright -->
<div class="copyright">
    <p>&#169; CarpoolVenom All Right Reserved.</p>
</div>
    <!-- Link To JS -->
    <script src="main.js"></script>
</body>
</html>
CSS Code
/* Google Fonts */
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@200;300;400;500;600;700&display=swap");
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  scroll-padding-top: 2rem;
  list-style: none;
  text-decoration: none;
  scroll-behavior: smooth;
  font-family: "Poppins", sans-serif;
}
:root {
  --main-color: #16b978;
  --second-color: #081b54;
}
section {
  padding: 50px 10%;
}
img {
  width: 100%;
}
*::selection {
  color: #fff;
  background: var(--main-color);
}
header {
  position: fixed;
  width: 100%;
  top: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 10%;
  transition: 0.2s;
}
header.active {
  background: var(--second-color);
  box-shadow: 0 0 4px rgb(14 55 54 / 15%);
}
header.active .logo {
  color: #fff;
}
header.active .navbar a {
  color: #fff;
}
.logo {
  display: flex;
  align-items: center;
  font-size: 1.1rem;
  font-weight: 600;
  color: #000000;
}
.logo img {
  width: 35px;
  margin-right: 10px;
}
.navbar {
  display: flex;
}
.navbar a {
  font-size: 1rem;
  padding: 10px 20px;
  color: #000000;
  font-weight: 500;
}
.navbar a:hover {
  color: #fff;
  background: var(--main-color);
  border-radius: 4px;
}
#menu-icon {
  font-size: 24px;
  cursor: pointer;
  z-index: 10001;
  display: none;
}
.home {
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  background: url(img/Background\ –\ 1@2x.png);
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center;
  gap: 1rem;
}
.home-text {
  flex: 1 1 17rem;
}
.home-img {
  flex: 1 1 17rem;
}
.home-text span {
  font-size: 1rem;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--main-color);
}
.home-text h1 {
  font-size: 4rem;
  color: var(--second-color);
}
.home-text p {
  margin: 0.5rem 0 1.4rem;
}
.btn {
  padding: 10px 20px;
  border: 2px solid var(--main-color);
  border-radius: 40px;
  color: var(--main-color);
  font-weight: 500;
}
.btn:hover {
  letter-spacing: 2px;
  color: #fff;
  background: var(--main-color);
}
.about {
  display: flex;
  align-items: center;
  flex-direction: column;
  background: url(img/about-bg.jpg);
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center;
}
.about h1 {
  font-size: 2.5rem;
  color: #fff;
  margin-bottom: 2rem;
  text-transform: uppercase;
}
.about-container {
  background: #fff;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  border-radius: 10px;
  border-top: 6px solid var(--main-color);
  padding: 20px;
  gap: 2rem;
}
.box-img {
  width: 200px;
  height: 200px;
}
.box-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}
.about-box {
  flex: 1 1 8rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.about-box h3 {
  font-size: 1rem;
  font-weight: 500;
  color: var(--second-color);
  margin: 0 0 0.5rem;
}
.about-box h2 {
  font-size: 1.2rem;
  color: var(--main-color);
  letter-spacing: 1px;
}
.heading {
  text-align: center;
}
.heading h2 {
  font-size: 2rem;
  color: var(--second-color);
  margin-bottom: 0.5rem;
}
.shop-container,
.customer-container {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 2rem;
}
.shop-box {
  position: relative;
  flex: 1 1 17rem;
  box-shadow: 0 4px 4px rgb(14 55 54 / 15%);
  border-radius: 0.5rem;
  height: auto;
}
.shop-img {
  width: 100%;
  height: 300px;
  border-radius: 0.5rem;
  overflow: hidden;
}
.shop-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}
.shop-img img:hover {
  transform: scale(1.1);
  transition: 0.5s;
}
.shop-box h3 {
  font-size: 1rem;
  font-weight: 500;
  color: var(--second-color);
  padding: 10px;
}
.shop-box h2 {
  font-size: 1.2rem;
  color: var(--main-color);
  letter-spacing: 1px;
  padding: 10px;
}
.shop-box .bxs-cart-add {
  position: absolute;
  right: 0;
  bottom: 0;
  font-size: 20px;
  padding: 10px;
  color: #fff;
  background: var(--main-color);
  border-radius: 4px 0 4px 0;
}
.shop-box .bxs-cart-add:hover {
  background: var(--second-color);
}
.customer-container .box {
  flex: 1 1 16rem;
  text-align: center;
  box-shadow: 0px 4px 4px rgb(14 55 54 / 15%);
  padding: 20px;
  border-radius: 0.5rem;
}
.box img {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--second-color);
}
.box .bx {
  color: var(--main-color);
  margin-top: 0.5rem;
}
.box p {
  margin: 0.5rem 0 1rem;
}
.box h2 {
  font-size: 1.2rem;
  color: var(--main-color);
  letter-spacing: 1px;
}
.contact-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  margin-top: 2rem;
}
.contact-info {
  flex: 1 1 20rem;
}
.contact-form {
  flex: 1 1 20rem;
  display: flex;
  justify-content: center;
}
.contact-info h2 {
  font-size: 1.7rem;
  color: var(--second-color);
}
.contact-info p {
  margin: 0.5rem 0 1rem;
}
.adress {
  display: flex;
  flex-direction: column;
}
.adress i {
  display: flex;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 20px;
}
.adress span {
  font-size: 1rem;
  margin-left: 1rem;
}
.social {
  margin-top: 1rem;
}
.social a {
  font-size: 24px;
  color: var(--main-color);
  margin-right: 1rem;
}
.social a:hover {
  color: var(--second-color);
}
.contact-form form {
  width: 100%;
  display: flex;
  flex-direction: column;
}
form input,
textarea {
  width: 100%;
  padding: 17px;
  border-radius: 0.5rem;
  outline: none;
  margin-bottom: 1rem;
  border: 2px solid var(--main-color);
  box-shadow: 0 4px 4px 2px rgb(14 55 54 / 15%);
}
form input::placeholder,
textarea::placeholder {
  color: var(--main-color);
}
form textarea {
  resize: none;
  height: 150px;
}
form .btn {
  max-width: 100px;
  background: var(--main-color);
  color: #fff;
  text-transform: uppercase;
  font-weight: bold;
  border: none;
}
form .btn:hover {
  background: var(--second-color);
}
.copyright {
  padding: 20px;
  text-align: center;
}
@media (max-width: 1100px) {
  .home-text h1 {
    font-size: 3rem;
  }
}
@media (max-width: 991px) {
  header {
    padding: 18px 4%;
  }
  section {
    padding: 50px 4%;
  }
}
@media (max-width: 768px) {
  header {
    padding: 11px 4%;
  }
  #menu-icon {
    display: initial;
  }
  header.active #menu-icon {
    color: #fff;
  }
  header .navbar {
    position: absolute;
    top: -500px;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    background: var(--second-color);
    box-shadow: 0 4px 4px rgb(14 55 54 / 15%);
    transition: 0.2s ease;
    text-align: right;
  }
  .navbar.active {
    top: 100%;
  }
  .navbar a {
    padding: 1.5rem;
    display: block;
    color: #fff;
  }
  .home-text h1 {
    font-size: 2.4rem;
  }
  .about h1 {
    font-size: 2rem;
  }
  .heading h2 {
    font-size: 1.6rem;
  }
  .contact-info h2 {
    font-size: 1.6rem;
  }
}
@media (max-width: 360px) {
  .home-text span {
    font-size: 0.8rem;
  }
  .home-text h1 {
    font-size: 2rem;
  }
  .home-text p {
    font-size: 0.9rem;
  }
}

JavaScript Code
let header = document.querySelector('header');
let menu = document.querySelector('#menu-icon');
let navbar = document.querySelector('.navbar');


window.addEventListener('scroll', () => {
    header.classList.toggle('active', window.scrollY > 0);
});

menu.onclick = () => {
    navbar.classList.toggle('active');
}
window.onscroll = () => {
    navbar.classList.remove('active');
}
Download Files

Comments

Contact Form

Send