I'm struggling to convert this vertical navigation bar into a horizontal layout using CSS

<nav class="navbar navbar-dark bg-dark sticky-top">
  <a class="navbar-brand" href="#">I/H</a>
  <div class="collapse navbar-collapse" id="navbarNav">
    <ul class="navbar-nav">
      <li class="nav-item active">
        <a class="nav-link" href="index.html">Home<span class="sr-only">(current)</span></a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#about">About</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#work">Work</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#connect">Connect!</a>
      </li>
    </ul>
  </div>
</nav>

I have been trying to convert this vertical list into a horizontal navbar using CSS, but I keep running into issues. I initially wanted to remove the toggle button to prevent layout changes when the dropdown menu is opened, but that didn't work as expected. After many failed attempts, I finally managed to solve the problem!

Answer №1

To make your navigation bar expand in Bootstrap, simply add the navbar-expand class...

Check out this example here

<nav class="navbar navbar-expand navbar-dark bg-dark sticky-top">
    <a class="navbar-brand" href="#">I/H</a>
    <div class="collapse navbar-collapse" id="navbarNav">
        <ul class="navbar-nav">
            <li class="nav-item active">
                <a class="nav-link" href="index.html">Home<span class="sr-only">(current)</span></a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#about">About</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#work">Work</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#connect">Connect!</a>
            </li>
        </ul>
    </div>
</nav>

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

You are limited to using a maximum of two custom tags within a custom div

I came up with this code that is supposed to style the elements differently based on their tag names. However, when I tested it, the styling did not work as expected. For example, 'London' should be displayed as a large and bold h1 text, while th ...

The show/hide jquery function is functioning perfectly on desktop devices, but issues arise on mobile devices where the divs overlap each other when using the show() method

I need a way to toggle input text boxes based on selection using a select box This is the HTML code snippet: <div class="row"> <div class="form-group"> <div class="col-sm-1 label2"> <label class="control-label ...

Using scale transformations to animate SVG group elements

I am currently experimenting with an SVG example where I hover over specific elements to expand or scale them. However, I seem to have made a mistake somewhere or missed something important. Can someone offer me assistance? View the demo on JSFiddle here ...

Error: The W3C Validator has identified a parsing issue related to the opacity setting of

After putting my stylesheet through the CSS validator at W3C, I encountered only one error which read "Parse Error Opacity=60". The issue seems to be in this specific part of the CSS code: /*Navigation Link styling */ #Nav a:link, a:visited { display: inl ...

Can CSS alone be used to provide a cover for auto-scaling images?

One common technique is using max-height and max-width to make an image automatically fit in a div, as shown below: .cover img { max-width: 100%; max-height: 100%; } But is there a way to create a translucent cover (with opacity set to 0.8) that ...

Modify the height of one or more <span> elements within a table cell

Is it possible in this scenario to automatically adjust the row height for <span class="orange">ORANGE</span>? And if there are two or more <span> elements, can the cell be split to accommodate varying heights? (You can use: display: tab ...

Adjust the height in proportion to the width

My goal is to adjust the height of the li's based on their width using JQuery. var width = $('li').width(); $('li').css('height', width + 'px'); However, I've encountered an issue as it doesn't resu ...

What is the best way to manage the changing selection in a drop-down list?

Can someone help me with a coding issue I am facing? <select name="txtTK" > <option value="None">---</option> <option value="Mat">Materials</option> <option value="Cate">Category</option> <option ...

ngif directive does not function properly when subscribe is utilized in ngOnInit

this is the unique component code import { Component, OnInit } from '@angular/core'; import { Subscription } from 'rxjs'; //import { Item } from '../item/item.model'; import { CartItem } from './cart-item.model'; imp ...

The XPath for the span element

Is there a way to obtain the Xpath of the specific element below? <div class="datum"> <span>180 KM</span> </div> The desired value is "180 KM". I am struggling to extract it because the span element lacks a name at ...

Position the <i> element to the right side of the <div> element in an HTML document

I am trying to make this <i> element align to the right within my <div>. Here is the HTML code I have so far: <div class="container-fluid p-1 bg-primary text-white d-flex align-items-center justify-content-center"> <h2&g ...

Ways to deactivate webfonts specifically for Safari

Recently, I have been experiencing font crashing issues with the webfont on Safari. Is there a way to disable this font specifically for this browser? ...

Displaying updated character counts in Angular directive based on various triggers

I am currently working on creating a characterCounter attribute directive specifically for input fields. My idea is to use 'ngModel' to access the length of the modelValue in ng-model, and to define a max-length within the directive's scope. ...

default radio option with pre-selected value

Below is a radio option list, but I'm having trouble getting the desired default selection on first render: <label class="radio normalFontWeight"> <input type="radio" name="Criteria" data-ng-value="EVERYONE_REVIEWED" data-ng- ...

Concealing overflow in a sticky container when a fixed child element is present

I am currently working on a website where I have implemented slide-up section panels using position: sticky while scrolling. However, I am encountering issues with fixed elements within the sticky panels not properly hiding outside of the respective sectio ...

Animating a dotted border path in SVG for a progress bar effect

I am attempting to create an animation for a dotted SVG circle that resembles a progress bar, where it fills itself over a duration of 3 seconds. However, I am facing difficulties in achieving this effect with the dotted border. The current code I have doe ...

Bootstrap 4 - positioning link element to align with heading in card header

I'm currently utilizing Bootstrap 4+ to design a card that features a collapsible card-body, triggered by a link located in the card-header. <div class="card text-left mb-3 mt-3"> <div class="card-header p-3"> <h4>Where should ...

Run javascript code after the page has transitioned

Struggling to create a dynamic phonegap app with jQuery Mobile, the issue arises when loading JavaScript on transition to a new page. The structure of my index page is as follows: <body> <div data-role="page" id="homePage"> <div data- ...

Scraping the web with Python: Selenium HTML elements may differ from what is shown in the inspect tool

In my current academic project, I am facing an issue with scraping news articles from websites. The problem arises when parsing HTML code in Python because the code obtained from the page source is different from what is shown in the Inspect Element tool. ...

I'm having trouble getting the font to display properly on Safari (mac) similar to how it appears on

Recently, I completed a website for a client at . The owner requested the footer text to be styled similarly to the footer text on . However, upon review, it seems that the font in the lists on desiringgod appears thinner compared to the site I built. Thi ...