Automatic responsive navigation bar in mobile view

As a novice in web programming, I'm facing an issue where the navigation bar shifts to the bottom when the mobile screen size changes. Many solutions online use the hamburger style, which I find less appealing.

Here is how the mobile view looks before resizing:

https://i.sstatic.net/75K1E.png

And here is the view after resizing the screen:

https://i.sstatic.net/5NUev.png

Below is the code snippet causing this problem:

.servicebtn,
.contactbtn,
.careerbtn,
.aboutbtn {
  height: 40px;
}

@font-face {
  font-family: "bebas";
  src: url('font-family/bebas/BEBAS.woff') format('woff');
}

@font-face {
  font-family: "cairo";
  src: url('font-family/cairo/Cairoreg.ttf') format('truetype');
}

.servicebtn,
.contactbtn,
.careerbtn,
.aboutbtn {
  font-family: cairo;
  text-transform: capitalize;
}

.nav-item {
  background-color: black !important;
  border-radius: 10px 10px 0px 0px;
}

.nav-item:hover,
.nav-item:focus {
  background-color: #01FF9D !important;
  color: white;
  border-radius: 10px 10px 0px 0px;
}

.boder {
  background-color: grey !important;
  color: black;
}

.active:focus {
  background-color: #01FF9D !important;
  color: white !important;
}

.nav-link {
  color: white;
  border-radius: 10px 10px 0px 0px;
}

.nav-link:focus,
.nav-link:hover {
  color: white;
}

.nav-tabs .nav-item.show .nav-link,
.nav-tabs .nav-link.active {
  color: black;
  background-color: #01FF9D !important;
  border-color: transparent !important;
  border-radius: 10px 10px 0px 0px !important;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b1d3dedec5c2c5c3d0c1f1849f809f82">[email protected]</a>/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">

<ul class="nav nav-tabs header">
  <li class="nav-item">
    <a class="nav-link text aboutbtn" aria-current="page" data-bs-toggle="tab" href="#about"><i class="fas fa-chalkboard-teacher"></i> About Us</a>
  </li>
  <li class="nav-item">
    <a class="nav-link text servicebtn" data-bs-toggle="tab" href="#service"><i class="fas fa-search"></i> Viewrify</a>
  </li>
  <li class="nav-item">
    <a class="nav-link text contactbtn" data-bs-toggle="tab" href="#contact"><i class="fa fa-user" aria-hidden="true"></i> Contact Us</a>
  </li>
  <li class="nav-item">
    <a class="nav-link text careerbtn" data-bs-toggle="tab" href="#career"><i class="fa fa-camera" aria-hidden="true"></i> Careers</a>
  </li>
</ul>

Despite trying @media queries, I couldn't resolve the issue and adjusting the width of nav-items did not yield any positive results as shown in the images.

Answer №1

Using the power of flexbox, accomplishing this task is simple. Give it a shot:

ul.nav.header {
    display: flex;
    flex-wrap: nowrap;
}

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

Eliminate the margin and padding on a floating table header

After scrolling, I am attempting to position the thead element. However, when changing the position from static to absolute, the element becomes offset with added margin and padding. This has led me to try using CSS to address the issue: To resolve this, ...

Expanding Bootstrap 5 navbar-nav to occupy entire screen space in collapsed state

Hello everyone, I hope you are doing well! I am currently working on a website project using Bootstrap 5 and have encountered an issue with the navbar toggler. While the toggler is functioning properly, I am having trouble making it fill the full width o ...

Activate Auto Navigation Feature on Mouseover using jQuery

I have a series of divs that cycle automatically to display their contents one after the other every few seconds. The same content is also displayed when the corresponding link is hovered over. The functionality is working correctly, but I would like to ...

Interactive sidebar scrolling feature linked with the main content area

I am working with a layout that uses flexboxes for structure. Both the fixed sidebar and main container have scroll functionality. However, I have encountered an issue where scrolling in the sidebar causes the scroll in the main container to activate whe ...

Align the <div> vertically within the <td> tag

My current set up looks something like this: <tr> <td> <div class="blue">...</div> <div class="yellow">...</div> </td> <td> <div class="blue">...</div> <div class="yellow ...

"My drop down button menus and background image seem to be experiencing some technical difficulties. Can someone help

I'm having trouble getting a drop-down menu to work with a reptile image as the background. When I remove the image, the drop-down works fine. I've checked for errors but can't seem to find any. Is it an issue with the code or maybe a typing ...

What are some ways I can decrease the background width and shrink the div width?

I am hoping to maintain the current box size and borders, but I want to add a touch of color. Specifically, I would like to have a red line running through the center of the box without coloring the entire background. Although I know one way to achieve thi ...

What is the best way to apply an SVG as the background-image for this text?

After examining the fiddle, it is clear that there is code to set the background of two spans to an image created with svg. The goal now is to achieve this dynamically using javascript (either jquery or raw) on the span with the "help" class, but unfortuna ...

Do you require a lightbox for a white text box set against a semi-transparent black background?

Currently, I am in the process of developing a Chrome extension that will be compatible with my Android app. As part of this development, I need to code the HTML/CSS for the extension. The main functionality of the extension allows users to add tags to a s ...

Display a specific paragraph inside a div using jQuery

I am having trouble getting my jQuery code to display a specific paragraph when a particular div is clicked on. My goal is for the content "v" to be displayed if the user clicks on the ".Virus" div, and for the contents of ".screenInfo" to be shown if the ...

Troubleshooting techniques for resolving CSS issues with the video.js package in ReactJS

When using video.js in react to build a video player, I encountered an issue with the npm package not providing its inbuilt CSS. How can I add the inbuilt CSS of video.js? Instead of the control bar, I am getting something different than what is shown in t ...

Vertical alignment can be a challenge with Bootstrap flex items

I’m currently facing an issue with centering the elements within the <main> tag. There seems to be a mysterious gap between the <h1> and <h3> elements, and I can’t seem to pinpoint the root cause of this spacing anomaly. Any insights ...

Choose a single SVG file based on its unique ID

Looking for some guidance - I have a vector file with 40 svgs all combined into one image. Each vector is identified by an id inside the <g> tag. How can I select a specific svg from this single file without choosing the entire image in html? PS: E ...

Embedding @keyframes within @media queries

I need to resolve an issue involving curly brackets. However, all opening brackets have a corresponding pair. There is an error on line 212 Expected RBRACE at line 212, col 2. @-webkit-keyframes move { Oddly enough, when I test the code separatel ...

Tips for achieving a blurred background image effect when hovering, while keeping the text unaffected

Hey there, I've recently started my journey into web development and have encountered a roadblock. I'm trying to blur the background image of a div on hover without affecting the text inside. I have an id called c1 where I used a javascript func ...

Find the element that is being scrolled in order to delete its attributes

Issue with the sidebar causing whitespace on mobile devices, and scroll properties need to be removed. When expanding the sidebar, white space appears below it. Various display modes have been tried, but they all push elements below instead of keeping th ...

Adding a class to a different UL tab from the tab div in jQuery tabs - a guide

Looking to implement a tabs navigation using jQuery without the jQuery Tabs UI. Essentially, when a user clicks on a list item, the script selects the list element with data-tab="X" and adds the class current, making the link visible (default op ...

What steps are needed to design a search bar similar to Zomato's?

I am looking to create a search bar that resembles the one on . I have managed to make a floating search box on top of my background image. However, I am unsure how to align various input fields and buttons side by side. Below is the current CSS code I am ...

What is the best way to incorporate an input bar in a Bootstrap panel header?

When designing a search box in my panel header, I floated both elements to get them onto the same line. Although functional, the vertical alignment of the title is displeasing and I am seeking a way to improve this without drastically changing its size. I ...

How to align horizontal UL navigation utilizing CSS sprite background

After numerous attempts, I am struggling to center a 4 element horizontal list using a sprite image as the li background within the footer div. My CSS and HTML code is as follows: #footer-share-links { width:400px; text-align:center; margin:10 ...