TimesCoding

Learn, Practice, and Excel with our Coding Tutorials!

Creating a Stylish and Responsive Bootstrap Menu with Colorful Toggle Icon

June 10, 2024 4 Min read BOOTSTRAP CSS HTML
Stylish and Responsive Bootstrap Menu

Below is a simple responsive Bootstrap 5 template that you can use as a starting point for your project. This template includes a stylish & modern navigation bar, a hero section, a content section, and a footer. It is fully responsive and adapts to different screen sizes.

HTML and CSS Code for Responsive Bootstrap Menu

index.html

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Bootstrap Responsive Template</title>
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
  <!-- Custom CSS -->
  <style>
    /* Custom Navigation Bar Styles */
    .navbar {
      background: linear-gradient(45deg, #007bff, #6610f2);
    }
    .navbar-brand {
      color: #fff;
      font-size: 1.5rem;
      font-weight: bold;
    }
    .navbar-nav .nav-link {
      color: #fff;
      margin-left: 15px;
      transition: color 0.3s ease, background-color 0.3s ease;
      padding: 0.5rem 1rem;
    }
    .navbar-nav .nav-link:hover {
      color: #007bff;
      background-color: #fff;
      border-radius: 5px;
    }
    /* Custom Toggle Button Styles */
    .navbar-toggler {
      border: none;
      background: transparent;
      outline: none !important;
    }
    .navbar-toggler .icon-bar {
      display: block;
      width: 22px;
      height: 2px;
      margin: 4px auto;
      transition: all 0.3s ease;
      background-color: #fff;
    }
    .navbar-toggler .icon-bar:nth-child(1) {
      transform-origin: top left;
    }
    .navbar-toggler .icon-bar:nth-child(3) {
      transform-origin: bottom left;
    }
    .navbar-toggler.collapsed .icon-bar:nth-child(1) {
      transform: rotate(45deg) translate(4px, 4px);
      background-color: #f0ad4e; /* Orange */
    }
    .navbar-toggler.collapsed .icon-bar:nth-child(2) {
      opacity: 0;
    }
    .navbar-toggler.collapsed .icon-bar:nth-child(3) {
      transform: rotate(-45deg) translate(4px, -4px);
      background-color: #5bc0de; /* Light Blue */
    }
  </style>
</head>
<body>
  <!-- Navigation Bar -->
  <nav class="navbar navbar-expand-lg">
    <div class="container-fluid">
      <a class="navbar-brand" href="#">Brand</a>
      <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <div class="collapse navbar-collapse" id="navbarNav">
        <ul class="navbar-nav ms-auto">
          <li class="nav-item">
            <a class="nav-link active" aria-current="page" href="#">Home</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="#">Features</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="#">Pricing</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="#">Contact</a>
          </li>
        </ul>
      </div>
    </div>
  </nav>

  <!-- Hero Section -->
  <section class="bg-primary text-white text-center py-5">
    <div class="container">
      <h1 class="display-4">Welcome to Timescoding.com</h1>
      <p class="lead">This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured content or information.</p>
      <a href="#" class="btn btn-light btn-lg">Learn More</a>
    </div>
  </section>

  <!-- Content Section -->
  <section class="py-5">
    <div class="container">
      <div class="row">
        <div class="col-md-4">
          <h2>Feature 1</h2>
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
        </div>
        <div class="col-md-4">
          <h2>Feature 2</h2>
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
        </div>
        <div class="col-md-4">
          <h2>Feature 3</h2>
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
        </div>
      </div>
    </div>
  </section>

  <!-- Footer -->
  <footer class="bg-light text-center py-4">
    <div class="container">
      <p class="mb-0">© 2024 Company, Inc. All rights reserved.</p>
    </div>
  </footer>

<!-- Bootstrap JS and dependencies -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
  <!-- Custom JS -->
  <script>
    document.addEventListener('DOMContentLoaded', function() {
      var navbarToggler = document.querySelector('.navbar-toggler');
      navbarToggler.addEventListener('click', function() {
        this.classList.toggle('collapsed');
      });
    });
  </script>
</body>
</html>

Save the above code in an “index.html” file.

Tags:

  • Responsive Bootstrap navbar tutorial
  • Stylish Bootstrap menu design guide
  • Colorful toggle icon Bootstrap navbar
  • SEO-friendly responsive navbar example
  • Customizing Bootstrap navbar toggle button
Related Post:
Trendy Website Color Combinations for 2024 − Here are some trending color combinations to consider for your website, including header, footer, sidebar, and content section colors with codes: 1. Balanced Brights: 2..
Create a Stylish Analog Watch with HTML, CSS, and JavaScript − Creating a stylish analog watch using HTML, CSS, and JavaScript involves simulating the appearance and movement of clock hands. We’ll build a simple analog clock.
How to Create a Stylish Digital Watch with HTML, CSS, and JavaScript − Creating a digital watch similar to an Apple Watch using HTML, CSS, and JavaScript involves several steps. We’ll build a simple, functional digital clock that.
Responsive Web Design with CSS: A Short Tutorial − Responsive web design is a crucial aspect of modern web development. It ensures that your website looks and functions well on a variety of devices,.
How to Create a Modern Stylish Accordion with Arrows Using Only HTML and CSS − This modern and stylish accordion is created using only HTML and CSS, featuring smooth transitions and interactive arrows that change direction upon expansion. It’s perfect.
How to Create a Stylish and Modern HTML Select Field Using CSS − Creating a modern and stylish HTML “Select” field involves using CSS to enhance the default styling. Here’s an example of how you can achieve this:.
Modern and Stylish Button with Gradient and Hover Effects − This modern and stylish button features a vibrant gradient background that seamlessly transitions on hover, coupled with a subtle box shadow for added depth. Its.
Creating a Modern Responsive Menu with HTML & CSS Only − Learn how to design a stylish and modern website header section and responsive menu using just HTML and CSS, with a responsive menu that toggles.
Design a Modern and Stylish Login Form using HTML and CSS − This is a modern and stylish login form using HTML and CSS, featuring 3D effects, colorful fields, and a button. The “Not registered? Create an.
Creating a Modern Button with Stylish Hover Effects Using CSS − This is a modern and stylish button with a simple hover effect using CSS. The button has a bold border & the border color will.
How to Create a Colorful Tic-Tac-Toe Game with HTML, CSS and JavaScript − Here’s a colorful Tic-Tac-Toe game implemented using HTML, CSS, and JavaScript only. The game includes a restart button, winner message, and special effects for the.
Pure CSS Custom Modern and Stylish Checkboxes − Creating a custom modern and stylish checkboxes using pure CSS can enhance the visual appeal of your web forms. Here’s a simple and elegant checkboxes.