Creating a responsive navigation bar with Bootstrap步 is simple and effective

Thank you for taking the time to review my current code. The main issue I am encountering pertains to the responsiveness of the navbar. Whenever I zoom in or out, certain elements tend to lose their alignment and aesthetic appeal. Specifically, the navbar brand fails to stay aligned to the left of the navbar, and the blue box in the top right corner becomes overly wide when zooming in.

My goal is to achieve a responsive design similar to Bootstrap's navbar, where the content remains intact when zooming out and adjusts accordingly when zooming in. Could you assist me in modifying my code to achieve this outcome?

You can view the code on Codeply here:

Here is my HTML code utilizing Bootstrap:

<nav class="navbar custom-navbar navbar-expand-lg bd-nav">
      <div class="nav-blue-bar">
        <p class="nav-blue-bar-content">
          <i class="fa-solid fa-square-phone"></i> &nbsp; 0000-111-2222 &nbsp;
          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
          <i class="fa-solid fa-envelope" style="color: #ffffff"></i>
          <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f7a4838293929583b7909a969e9bd994989a">[email protected]</a>
        </p>
        <p class="nav-blue-bar-content-right">
          We are now taking intakes for mat, Limited seats
        </p>
      </div>
      <div class="container">
        <a class="navbar-brand" href="#">Your Brand</a>
        <hr class="line-1" />
        <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="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse navbar-center" id="navbarNav">
          <ul class="navbar-nav">
            <li class="nav-item">
              <a class="nav-link" href="#">Home</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="#">Courses</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="#">Universities</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="#">About</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="#">Gallery</a>
            </li>
          </ul>
        </div>
      </div>
    </nav>

And here is the accompanying CSS:

body {
  max-width: 1920px;
  margin: 0 auto;
  min-width: 1000px;
}

.nav-blue-bar {
  z-index: 1;
  position: absolute;
  top: 0;
  right: 0;
  width: 90%;
  left: 266px;
  height: 35px;
  background-color: #192f59;
  clip-path: polygon(0% 0%, 100% 0%, 980% 100%, 3% 100%);
}

.nav-blue-bar-content {
  position: absolute;
  top: 5px;
  left: 100px;
  color: #ffffff;
  margin: 0;
  font-size: 14px;
}

.nav-blue-bar-content-right {
  position: absolute;
  top: 5px;
  right: 20%;
  color: #ffffff;
  margin: 0;
  font-size: 14px;
}

.custom-navbar {
  background-color: #f4f5f7;
  min-height: 100px;
  overflow: hidden;
  max-width: 100vw;
}

.navbar-brand {
  font-size: 34px;

  font-weight: bold;
  color: #192f59;
  margin-left: 0%;
}

.nav-link {
  font-size: 18px;
  color: #000000;
}

.navbar-center {
  display: flex;
  justify-content: center;
  padding-right: 15%;
}

.nav-item {
  padding-right: 60px;
  padding-top: 35px;
}

.line-1 {
  position: relative;
  width: 10%;
  height: 0px;
  left: -36px;
  top: 10%;
  opacity: 1;
  border: 1px solid;
  border-color: #192f59;
  transform: rotate(116.03deg);
}

I am aiming for a design where the content remains fixed when zooming in. Both the navbar and the hr element should align to the left. For reference, this is the format and design I am striving to achieve: Link to Desired Design

Answer №1

If you want your container to be full width, try using the container-fluid class instead of container. After that, you can use the d-flex class (which stands for display: flex) along with justify-content-between to align your box and navbar links. I believe this will be beneficial for you.

I trust this information has been helpful to you!

Wishing you a wonderful day ahead!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Combining BackgroundImage and Overlay in React for a Stylish Overlapping

I was looking to add a background overlay on my background image. Below is what I was trying to achieve: https://i.sstatic.net/NaZ6L.png Please take a look at my codesandbox as well Click here image: { backgroundImage: "linear-gradient(0 ...

What is the best way to integrate my company's global styles CDN for development purposes into a Vue cli project using Webpack?

After attempting to import through the entry file (main.js)... import Vue from 'vue' import App from '@/App' import router from '@/router/router' import store from '@/store/store' import BootstrapVue from 'boot ...

Assign a specific style to Fancybox links and buttons for managing the functions of 'next', 'previous', and 'close'

Utilizing the following jQuery script to hide a div whenever anything that does not have the class 'click' is clicked (used for empty space and certain other divs). $(document).click(function (event) { if (!$(event.target).hasClass('cli ...

Switching out one block of HTML with another in JavaScript is a powerful way to dynamically update

I am working on creating a feature on a webpage where clicking a button will change the HTML code inside a specific div. Essentially, I want to be able to update the content of a div by simply clicking a link. Here are two different sets of HTML code: Co ...

Half of the sections will not stack on mobile devices

UPDATE I found and fixed a typo in the code, making adjustments to both the JSFiddle and this post to show the correction. The Headline is supposed to take up 100% height but currently isn't. Still seeking feedback on this issue. Everything looks per ...

What is the best way to achieve a perfect rounded div using Bootstrap 4?

While browsing through the Bootstrap documentation and searching on stackoverflow, I came across a solution to create circular images using border-radius set at 50%. However, when I tried implementing it with my slightly oversized image, it ended up lookin ...

Tips for changing the color of MUI TextField in React.JS?

Is there a way to customize the color of the TextField frame? It always shows up as black, making it hard to use in dark mode. I am looking to change the color of both the label and the input line. return ( <div align="center" ...

The swipe function of Hammer.js is unable to detect gestures on a rotated iframe

After creating a rotated iframe on the page using CSS transforms, I attempted to implement swipe events within the iframe. body.rotate iframe { transform: rotate(90deg); transform-origin: top right; position: absolute; t ...

Override the class inside the ul div

I am utilizing Dreamweaver's Spy menu without any sub items. By using a background image for "not active", another for "rollover" and attempting to apply one for "active". I have created a class for "active" and assigned it to one of the ul items. How ...

Unexpected Placement of CSS Grid Items

I am currently facing an issue with aligning items in a nested grid using grid-column/grid-row assignment. After setting the template with grid-template-rows:/grid-template-columns, I expected the $50 and Give Now items to appear on row 3, with one in colu ...

What is the reason for Safari 13 not displaying the outline during focus when a transition is applied?

In the current scenario, focusing on the button in Safari 13.0.5 does not display the outline until a repaint is forced (such as changing screen size). This issue does not occur in other browsers. Are there any workarounds or hacks to ensure the outline ...

How can I design an avatar image within a button similar to Facebook's style?

I'm currently working on a project that involves adding an avatar and a dropdown menu for account settings to my navigation bar. I've already created the dropdown, but I'm having trouble styling the avatar within the button. The button is ta ...

Is it possible to showcase a FullCalendar event in full width while being positioned behind other events scheduled for the same time slot?

Is there a way to customize FullCalendar so that concurrent events in the same timeslot are not vertically divided? I have a Google calendar named "time-blocking template" where I want all events to take up 100% of the timeslot width, even if there are ot ...

The issue of jumpy CSS background on full screen mode for mobile devices is causing

While developing a web app, I encountered an issue with the responsive (parallax) full screen background. On mobile devices, the background does not extend below the toolbar, causing a jumpy effect when scrolling up and down in Firefox. I have tried differ ...

Transitioning Dropdowns in Angular UI Bootstrap

Hello everyone, I am completely new to both Stack Overflow and AngularJS. I'm attempting to incorporate a fade-in animation into my dropdown (using UI Bootstrap's dropdown directive) without success. This issue is quite similar to the following ...

Creating a webpage that seamlessly scrolls and dynamically loads elements

Currently, I am working on a dynamic website that loads new elements as you scroll down the page. Here is an example of the HTML code: <div>some elements here</div> <div id="page2"></div> And this is the JavaScript code: var dis ...

How do I go about uploading the code as instructed on the platform's e-commerce details page?

.mk_01{ color: #000000; font-size: 30px; font-style: normal; font-family: Baskerville, "Palatino Linotype", Palatino, "Century Schoolbook L", "Times New Roman", serif; text-align: center; } .mk_02{ color: #000000; fon ...

How to attach an event listener to an input element using Angular

I am looking to add a listener to an input element that will be triggered every time the user changes the input values. The goal is to display the current values chosen by the user. Example HTML template: <div id="idDoseLabel1" class="da ...

Steps for accessing CSS variables within a scoped style block in Vue with Buefy_integration

After diving into the Buefy documentation, I successfully personalized my color scheme and even crafted unique hues by applying the is-[colorName] as a class to HTML elements. <style lang="scss"> // Importing Bulma's core @import "~bulm ...

Tips for applying CSS styles to the active page link

Check out the code below: Is there a way to assign a specific class to the current page link so that the mouse cursor will display as default rather than changing to a hand icon? I'm looking for a solution where I can apply a class to the active lis ...