The CSS float is positioned beneath the Bootstrap navigation bar

Having an issue with the menu bars in my Rails 4 app. Specifically, I'm struggling with two divs overlapping.

The goal is to align the "Register" and "Log In" blocks with the left-hand side menu while floating right. It should not float slightly below the Bootstrap 3 nav div like it currently does:

This problem is especially noticeable when a user signs in or out:

The sidebar displaying "Register" or user name and "Log In" or "Log Out" is within the class nav pull-right. The relevant part of code from bootstrap.css appears to be this:

.pull-right {
float: right !important;
}

Here is a snippet of my application.html.erb code:

<div class="navbar navbar-fixed-top">
<div class ="navbar-inner">
<div class="container">
<b><a href="#" class="brand">WHEELS Registration</a></b>
<ul class ="nav">
<%= link_to "All Events", events_path %>
</ul>
<ul class="nav pull-right">
    <% if user_signed_in? %>
    <li><%= link_to current_user.full_name, edit_user_registration_path %>  </li>
    <li><%= link_to "Log Out", logout_path %></li>
    <% else %>
      <li><%= link_to "Register", register_path %></li>
      <li><%= link_to "Log in", login_path %></li>
    <% end %>
  </ul>
  </div>
  </div>
</div>
<div class="container">
<% flash.each do |type, message| %>
   <div class = "alert <%= flash_class type.to_s %> ">
  <button class="close" data-dismiss="alert">x</button> 
  <%= message %>
 </div>
<% end %>

<%= yield %>
</div>

You can access the app here for further assistance:

(I haven't included the Ruby on Rails tag as this seems more focused on CSS and bootstrap concerns, but will add it if deemed necessary)

Answer №1

To enhance the layout of your header, consider including a pull-left class within a div that houses other header elements. Your code might look something like this:

[...]
<div class="container">
    <div class="pull-left">
        <b><a href="#" class="brand">WHEELS Registration</a></b>
        <ul class ="nav">
        <%= link_to "All Events", events_path %>
        </ul>
    </div>
    <ul class="nav pull-right">
        [...]

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

Enhance the appearance of Font Awesome stars by incorporating a hover effect

Is there a straightforward way to make them turn solid yellow when you hover over them? const styles = theme => ({ root: { flexGrow: 1, overflow: 'hidden', padding: theme.spacing(0, 3), }, paper: { maxWidth: 800, mar ...

Unable to implement Bootstrap 5 Hamburger Animation - Looking for solutions

SOLVED I successfully resolved the issue :) The challenge was: $(function () { $('.navbar-toggler-button').on('click', function () { $('.animated-hamburger').toggleClass('open'); //Chrome expert mode ...

Background Color Not Displaying in CSS3 Preloader Code

Utilizing a CSS3 Designed Preloader for my website with some unique keyframe animations. #preloader { position: absolute; top: 50%; left: 50%; -webkit-transform: translate(-50%, -50%); transform: translate(-50 ...

Explanation for aligning anchors within an HTML <div>

I'm faced with this HTML snippet: <div class="row"> <div class="col-md-10 social-icons"> <a href="https://www.youtube.com/" target="_blank"><img src="/images/youtube-i.png"></a> <a href="https://gi ...

Choose all of the IDs from various sections using Jquery

I am facing an issue with having 2 identical IDs inside 2 separate sections. When the button is clicked, I want it to select the ID within this section and apply a style, then also select the ID in the other section and apply that same style. The code sni ...

What is the significance of z-index in relation to relative and absolute positioning?

Is there an issue with z-index when working with a div that has absolute position relative to another div? I am trying to place the absolute div below the other one, but it always appears on top. How can I resolve this problem? ...

Why does my anchor disappear after a second when clicked to show the image?

Hi everyone, I'm having an issue with a dropdown menu that I created using ul and anchor tags. When I click on one of the options, an image is supposed to appear. However, the problem is that the image shows up for just a second and then disappears. I ...

Maintaining the dropdown in the open position after choosing a dropdown item

The dropdown menu in use is from a bootstrap framework. See the code snippet below: <li id="changethis" class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown>LINK</a> <ul class="dropdown-menu"> <li id ...

Tips for choosing a table row that is not the first or last cell

#MyTable tr+tr:hover { background: #dfdfdf; } <table id="myTable"> <tr> <td>A</td> <td>B</td> <td>C</td> </tr> <tr> <td>1</td> <td>2</td> &l ...

Can you please explain the primary distinction between these two identification numbers?

Can you explain the distinction between the following two css ids? p#id1 { insert code here } and #id1 p { insert code here } ...

Customizing an external module class using CSS module pattern in React

Is there a way to locally override an external module's CSS class for a specific component? Here is my current code: import `style` from './style.module.css' // local CSS module import `ExternalComponent` from 'ExternalComponent&apos ...

What is the best way to assign a unique color to two overlapping cells in an HTML table using HTML and jQuery?

I have a task to highlight a row or column when a checkbox is selected, similar to the example shown in the image below. How can I adjust the code so that the overlapping cell gets a different color instead of green or yellow? For instance, in the image b ...

Formatting Issue with HTML Form (Width Exceeding Specifications)

Currently, I am in the process of creating a table that contains various forms and buttons within the cells. However, there seems to be excess space between the buttons which is giving the appearance of the form being too wide. I have been attempting to di ...

Highlight the navigation transition in the menu

Is there a more updated tutorial available for creating an underline effect that slides from one link to another when hovered over and remains at the clicked link? I have come across a tutorial on Underline transition in menu which seems to be based on th ...

Display a small icon within a checkbox input element inside a label

I have a customized input checkbox that looks like a button, but I want to add a small info icon in the lower right corner using a glyphicon. Currently, this is what I have: <div class="col-sm-4"> <label class ...

css - aligning text below another text in the center

Looking to style a text in a specific color with a message about another text below it? Want the text centered but not sure how to position it correctly? margin: 0px auto; If this code isn't delivering the desired result and is positioning your text ...

Ways to keep the footer at the bottom of the page without relying on the fixed positioning method

I’ve been tackling a responsive design issue on my website but I can't quite get the footer to stick at the bottom of the page. The 'fixed' property hides half of my text on mobile devices, so I turned to this solution (https://getbootstra ...

The CSS Grid container fails to resize based on the content inside

I am facing an issue with the grid element inside a parent container with display: grid;. The parent container has a maximum size and allows scrolling for the grid if necessary. The problem is that the grid element does not expand to fit its children. Whe ...

What is the best approach to make the child element function properly within my CSS grid design?

I've been struggling to set up a 3-column grid with 2 rows for showcasing my projects on my portfolio. Unfortunately, they are only appearing in the first column and I can't figure out how to fix it. Here's a visual representation of the is ...

align text vertically over an image

I've come across this question many times, but none of the answers seem to solve my issue. My challenge is centered around aligning text on an image with regards to vertical positioning. Below is the code I'm working with: <div class="col-sm- ...