The Bootstrap navigation bar is struggling to contain all of the list items,

Recently, I started working with the latest version of Bootstrap and encountered an issue with the navigation bar. Everything looks great until I start resizing the browser width. While other Bootstrap components adjust well to the resize, the list items in the navbar seem to get jumbled up in a strange order. I initially thought it might be related to collapsing, but now I believe it could be more about padding or width settings. I haven't made any changes to the Bootstrap CSS. Any suggestions on where I should begin troubleshooting this?

<div class="container-fluid">
    <div class="container-fluid" id="header">
        <div class="navbar navbar-default" role="navigation">
            <div class="container-fluid">
                <ul class="nav navbar-nav">
                    <a class="navbar-brand" href="#">
                        <img alt="Logo" src="./html/Images/logo.png" height="20" />
                    </a>
                    <a class="navbar-brand" href="./index.html">My Navbar</a>
                        <li><a href="./html/page1.html">List item 1</a></li>
                        <li><a href="./html/page2.html">List item 2</a></li>
                        <li><a href="./html/page3.html">List item 3</a></li>
                </ul>
            </div><!-- /.container-fluid -->
        </div>
    </div>

For reference, here's the fiddle: https://jsfiddle.net/y6k4jvv5/3/

Answer №1

Wrap the two a tags with li tags and apply CSS to make them float left

<div class="container-fluid">
    <div class="container-fluid" id="header">
        <div class="navbar navbar-default" role="navigation">
            <div class="container-fluid">
             <ul class="nav navbar-nav">   
                   <li><a  href="#">
                        <img alt="Logo" src="./html/Images/logo.png" height="20" />
                       </a></li>
                   <li><a  href="./index.html">My Navbar</a></li>

                        <li><a href="./html/page1.html">List item 1</a></li>
                        <li><a href="./html/page2.html">List item 2</a></li>
                        <li><a href="./html/page3.html">List item 3</a></li>
                </ul>
            </div><!-- /.container-fluid -->
        </div>
    </div>

li {
   float: left;
}

https://jsfiddle.net/y6k4jvv5/4/

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

Jquery problems impacting every element rather than only one

I'm currently experimenting with a small project where I have multiple div elements containing an image, h1 tag, and p tag all sharing the same class name. My goal is to add CSS effects that make the h1 tag and p tag slide into view and become visible ...

Getting table data from a Django database and displaying it on an HTML page

Currently, I am working with a Django table that has 3 fields. I have a total of 4 entries in this table, but I only want to display 2 of the 3 fields in a table. However, I am struggling with achieving this as I have only been able to display 1 row instea ...

Sending a base64 image of a canvas to a servlet

I have a JavaScript function that uploads HTML5 canvas base64 image data to a servlet. Here is the code: function saveDataURL(a) { var postData = "canvasData="+a; var ajax = new XMLHttpRequest(); ajax.open("POST",'uploadPhoto.cgi',tr ...

Issue with styling Icon Menu in material-ui

I'm having trouble styling the Icon Menu, even when I try using listStyle or menuStyle. I simply need to adjust the position like this: https://i.sstatic.net/n9l99.png It currently looks like this: https://i.sstatic.net/WeO1J.png Update: Here&apo ...

Tips for resolving the issue of CSS blocks disappearing when designing a webpage

When creating a responsive web page, the child block "overflows" from the parent block. This causes the entire page to shift to the left and an empty bar appears on the right side, moving all the content. I need to ensure that all content is positioned cor ...

Inconsistent functionality: Twitter Bootstrap tabs malfunction when placed inside a modal

Within a rails application, I have successfully implemented loading the content of a modal window (bootstrap modal) using Ajax. The challenge arises when trying to integrate tabs (bootstrap tabs) within this loaded content. While the tabs are displayed co ...

Styling tables with borders in CSS

If a table is set to have a border at a high level, how can I ensure that classes inheriting from it do not have any borders set? table,td,th { border: 1px solid #0B6121; } How can I make sure that my other table has no borders at all? table.menu { ...

The colorbox label cannot be interacted with

In a simple colorbox that I have loaded, I am using the following code: $.colorbox({html: $('#widget-login').html()}); Within the colorbox, there is a form consisting of an input field and a label: <form name="f-login" id="f-login" action=" ...

Extract the content within the span tags while preserving any line breaks

I have a situation where a span element contains text with line breaks, and there is a function in place to copy this content to the clipboard. My goal is to maintain the line breaks when the data is pasted into another tool or page that supports HTML. C ...

Error importing reach-router in Gatsbyjs causing website to break

While working on my Gatsby project, I decided to incorporate the React Cookie Consent package. However, upon installation and implementation attempt, my website crashed, displaying this error message: warn ./.cache/root.js Attempted import error: &a ...

Is it possible to make a div's width 100% until a certain point, and then change it to 30% beyond that breakpoint?

I am trying to work with a div element <body style="width: 100vw; height: 100vh"> <div id="containerDiv"> <div id="canvasDiv" /> </div> </body> My goal is to adjust the width of canvasDiv based on the screen size. ...

What is the process of dynamically loading CSS into an HTML document?

In my C# program, I am utilizing a web browser control and setting its HTML property programmatically by loading it from an HTML string variable. While this setup works almost perfectly, I have noticed that it loses the reference to the CSS file. I believe ...

When you add the /deep/ selector in an Angular 4 component's CSS, it applies the same style to other components. Looking for a fix?

Note: I am using css with Angular 4, not scss. To clarify further, In my number.component.css file, I have: /deep/ .mat-drawer-content{ height:100vh; } Other component.css files do not have the .mat-drawer-content class, but it is common to all views ...

Reduce the text of the link

Trying to simplify a task, but I'm struggling with the solution. What I want to achieve is shortening a link to 30 characters and adding ... at the end if it's longer. Also, I'd like to make it possible to see the full link on hover similar ...

Apply a border to the div that has been selected

I have a tool for storing information and I am using *ngFor to display each instance in a line. Is there a way to add a border when clicking on a line? The border should only appear on the clicked line, disappearing from the previous one if another line i ...

Initially unchecked Django Model Boolean Field with initial=False and required=False does not seem to be functioning as intended

Forms.py class CustomPostedForm(forms.ModelForm): posted = forms.BooleanField(required=False, initial=False) Views.py postform = CustomPostedForm(request.POST, instance=author) if postform.is_valid(): postform.save() ...

CSS/SCSS/JS: Adjusting header height dynamically while keeping it fixed at the

Check out my Codepen demo here: https://codepen.io/nickfindley/pen/dJqMQW I am seeking to replicate the current behavior of the page without specifying a fixed height for the header. The goal is to make the header adjust dynamically based on the content, ...

What could be the reason for my CSS animation with :hover @keyframes not functioning?

As a newcomer, I am struggling to understand why this code isn't functioning correctly. My goal is to create the illusion of a flying bird. This is my HTML: <img src="http://dl.dropboxusercontent.com/u/105046436/tw.png" /> <br> <div c ...

Display a message in jQuery when the same option is chosen more than once

I need help with my form that has an input text field and a select dropdown. Here is the markup: <div id="form-wrap" style="width:500px; margin: 0 auto;"> <table> <tr> <th width="55%">Service Name</th> ...

Troubleshooting: Issues with CSS fixed positioning

Whenever I try to scroll down, my navbar moves along with the page. Even when I resize the window, it keeps shifting despite using position:fixed. What mistake am I making? nav li:nth-child(1) { position: fixed; border: 1px solid #15317E; font-si ...