Bootstrap 2 - Condensed menu logo and toggle button aligned horizontally

Unfortunately, I'm facing a challenge with Bootstrap 2 in my current project. I am having difficulty getting the logo (.brand) and navigation toggle to be on the same line when the navbar collapses to the 'phone' level.

I attempted changing the .row to .row-fluid, but the .span6 elements still collapse and span the entire width of the navbar once it reaches 'phone' size.

Below is the current markup I am working with:

<div id="header-row">
    <div class="container">
      <div class="row-fluid">
              <!--LOGO-->
              <div class="span3"><a class="brand" href="/"><img src="img/logo.png"/></a></div>
              <!-- /LOGO -->

            <!-- MAIN NAVIGATION -->  
              <div class="span9">
                <div class="navbar pull-right">
                  <div class="navbar-inner">
                    <a data-target=".navbar-responsive-collapse" data-toggle="collapse" class="btn btn-navbar"><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></a>
                    <div class="nav-collapse collapse navbar-responsive-collapse">
                    <ul class="nav">
                        <li<?php if($current_file == 'index.php') {echo ' class="active"';}?>><a href="/">Home</a></li>

                        <li><a href="/#payback-time">Payback Time</a></li>
                        <li<?php if($current_file == 'funding.php') {echo ' class="active"';}?>><a href="/funding.php">Funding Options</a></li>
                        <li<?php if($current_file == 'supply-and-installation.php') {echo ' class="active"';}?>><a href="/supply-and-installation.php">Supply and Installation</a></li>
                        <li<?php if($current_file == 'contact.php') {echo ' class="active"';}?>><a href="/contact.php">Contact</a></li>

                    </ul>
                  </div>

                  </div>
                </div>
              </div>
            <!-- MAIN NAVIGATION -->  
      </div>
    </div>
  </div>

Additionally, I have customized some navbar properties based on the theme I am using:

#header-row{
	background: #f5f5f5;
	border-bottom:1px solid #eee;
	padding: 15px 0;
}

#header-row .navbar{margin:10px 0 0 0;}

#header-row .navbar .navbar-inner{
	border:none;
	box-shadow: none;
	margin: 0;
	background: transparent;
}

#header-row .navbar .navbar-inner ul.nav > li > a{
	box-shadow: none;
	background: transparent;
	color: #90c57b;
}
#header-row .navbar .navbar-inner ul.nav li.active a{
	color: #333;
}

Live code demo

Answer №1

To ensure that your logo and menu are displayed correctly on mobile screens, you need to align them within the bootstrap navbar structure. Currently, the logo is positioned outside of the navbar causing display issues. You can refer to the following example code which demonstrates how to set up a bootstrap 2 navbar. Your CSS should still be compatible with this setup, but some slight adjustments may be required. Feel free to plug in the code and test it out.

<div id="header-row">
    <div class="container">
      <div class="row-fluid">
        <nav class="navbar navbar-default">
          <div class="navbar-inner">
            <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
            </a>
            <a class="brand" href="#"><img src="http://crf.jamesallison.co/img/logo.png" /></a>
            <div class="nav-collapse collapse">
              <ul class="nav  pull-right" role="navigation">
              <li <?php if($current_file == 'index.php') {echo ' class="active"';}?>><a href="/">Home</a></li>
              <li><a href="/#payback-time">Payback Time</a></li>
              <li <?php if($current_file == 'funding.php') {echo ' class="active"';}?>><?php if($current_file == 'funding.php') {echo ' class="active"';}?><a href="/funding.php">Funding Options</a></li>
              <li <?php if($current_file == 'supply-and-installation.php') {echo ' class="active"';}?>><a href="/supply-and-installation.php">Supply and Installation</a></li>
              <li <?php if($current_file == 'contact.php') {echo ' class="active"';}?>><a href="/contact.php">Contact</a></li>
              </ul>
            </div>
          </div>
       </nav> <!-- /navbar-end -->
    </div>
  </div>
</div>

By implementing this code, you will resolve the issue of the logo and menu hamburger being on separate lines at smaller screen sizes.

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

Tips for ensuring a button stays anchored to the bottom of a flatlist while scrolling to the end in React Native

const Layout = () => { return ( <View style={styles.container}> <Text style={styles.heading}>Screen Data</Text> <View> <FlatList data={data} renderItem={({item}) => ( ...

Expanding Column Width Dynamically with Bootstrap When Text is Added

My HTML Code presents a challenge that I need help with: <!DOCTYPE html> <html lang="en"> <head> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.mi ...

Using JavaScript Object Constructor to alter text color

Seeking some guidance as a newbie here on how to deal with a problem I'm currently tackling. I understand that using an object constructor may not be the most efficient way to handle this, but I'm eager to enhance my knowledge of objects. My quer ...

How to prevent mousewheel scrolling on an HTML page with the exception of a specific div using jQuery

Is there a way to prevent mousewheel scrolling on an HTML page while still allowing it on a specific element? I've tried using the code below: $('html').bind("mousewheel, touchmove", function(e) { e.stopPropagation(); return false; ...

Generate fresh input fields with distinct identifiers using JavaScript

My challenge is to dynamically create new empty text boxes in JavaScript, each with a unique name, while retaining the text entered in the previous box. I struggled with this for a while and eventually resorted to using PHP, but this resulted in unnecessar ...

What is the method to deactivate child elements within an element that possesses the disabled attribute in Polymer?

What are some effective methods for disabling children elements when at least one parent element is disabled? I have a form with nested groups and fields that can be disabled based on certain conditions. Different parent elements may be disabled independe ...

Can the size of a linear gradient be predetermined in CSS?

When working with CSS, it's possible to set various properties of a linear gradient such as color, position, orientation, and width. However, is it feasible to define its length? I prefer not to use SVG and am specifically looking for a CSS-based solu ...

Difficulty encountered while setting up jQuery slider

I am struggling to set up a jquery slider (flexslider) It seems like I am overlooking something very fundamental, but for some reason I just can't figure it out. Any assistance would be greatly appreciated. Please check out the link to the test site ...

Validation for optional fields in asp.net mvc 5

In my asp.net mvc 5 application, I have a form with some fields that are optional and not required to be filled. Despite trying different approaches, I keep getting a warning message stating that these fields are required. [Required(AllowEmptyStrings = t ...

What is the purpose of a single-row border with a top and bottom border that

Just to let you know, I'm new here so please be patient with me ;) I'm having an issue styling my foreach loop. My goal is to have a single line border appear at the top and bottom of each row when hovered over. However, the problem is that when ...

Modifying the default hover color of a specific row in AgGridReact

How can I eliminate the row color changing behavior in AgGrid tables when a row is selected and hovered over using React? Currently, a default dark gray color is applied when I hover over certain elements of a selected row, which is not desired in my imple ...

Tips for ensuring a row and its columns take up the full height of their parent element (jumbotron)

https://i.sstatic.net/1LtQ8.jpg I need assistance with aligning the slogan vertically and horizontally within the jumbotron. The top logo is positioned correctly, but I want the small icon to be at the bottom of the jumbotron. Any help would be greatly a ...

Struggling to connect HTML with CSS in Hugo

I am experimenting with a pre-fabricated theme in Hugo and incorporating some Bootstrap codes. I want to change the color of all links when displayed or hovered over. Despite searching extensively, I have been unable to achieve this through the use of CSS ...

Can PHP offer a more streamlined method for displaying the chosen item from SQL in a dropdown menu?

I am attempting to extract the name of the country from the database and display the chosen country. The current method I am using involves listing all 193 countries individually, which seems inefficient. Is there a simpler way to accomplish this task? & ...

Utilizing AWS S3 Raster Files with Mapbox gl js: A Step-by-Step Guide

Utilizing a Cloud-Optimized Geotiff raster layer with Mapbox GL JS I believe I need to use a raster source, and the data in the source must be tiled. The URL format should be something like .../{z}/{x}/{y}.tif. However, I am unsure of how to create the a ...

Chrome reload causing page to automatically scroll to bottom on my website

Could really use some assistance in solving this problem as I am completely stumped. I've noticed an issue on one of my websites when pages are reloaded. Every now and then (not consistently, which adds to the confusion), upon refreshing a page, it ...

Alignment of Bootstrap input groups and buttons

I am looking to have the input group aligned on the left side and the "Add New" button aligned on the right side of the row. <div class="row"> <div class="input-group col-sm-6"> <input type="text" class="form-control" placehol ...

How can the carousel item numbers be adjusted for proper display?

I'm currently working on an Angular app and have encountered a task related to displaying 5 cards using mdbootstrap. I want to showcase these cards in a carousel format, but with a twist - I only want the carousel functionality to be active on mobile ...

Processing file to retrieve information (JavaScript)

As someone who is new to the world of JavaScript and website development, please forgive me if this question seems a bit basic. The concept is to have a popup message appear on every page with some information. The issue arises when wanting to change this ...

Outputting a variable using javascript

My challenge is to efficiently print the contract variable, which contains HTML content fetched from the server. How can I achieve this easily? I want the print window in Chrome to display the document with the contents of my variable when I click a button ...