The Bootstrap Grid System is failing to produce the intended results

Recently, I incorporated Bootstrap into an older Rails project to utilize the grid system for aligning the main content and sidebar. Here's a code snippet from my "view" file (index.html.erb).

    <div class="container-fluid">
        <div class="row">
            <div class="col-md-8"> 
              <div id="featured_gallery" class="wide_content_box rounded_border">
                <%= content_tag :div do %>
                <%= content_tag :span, :class => "results_head" do %>
                <%= _('Featured gallery') %>: <%= link_to(truncate(h(@featured_gallery.name), :length => 30), @featured_gallery) %>
                <% end -%>
                &nbsp;&nbsp;&nbsp;&nbsp;<%= more_link(galleries_path(:filter => 'featured')) %>
                <% end %>
                <%= render :partial=> "projects/project", :collection=> @featured_gallery_projects %>
                <div class="clear">
                    &nbsp;
                </div>
            </div>
        </div>

    <div class="col-md-4">
                <div id="greeting">
                    <div id="hi">
                        <%= user_thumbnail(current_user, :thumb_tiny) %><%= random_hi %>
                    </div>
                    <div class="clear">
                        &nbsp;
                    </div>
                </div>
            <div class="clear">
                &nbsp;
            </div>
    </div>
  </div>
 </div>

However, attempting to align these two sections next to each other led to unexpected results. Any insight on how to correct this alignment issue would be greatly appreciated. Ideally, the online users section, featured gallery, and others should appear in a column to the right of the primary content.

UPDATE: The divs are properly nested. To test, I added another row above the existing one with the following code:

<div class="row">
        <div class="col-xs-4">
            First column!
        </div>
        <div class="col-xs-4">
            "Second column"
        </div>
        <div class="col-xs-4">
            Third column!
        </div>
    </div>

Even this setup resulted in the three columns stacking on top of each other rather than appearing side by side in the same row. This unexpected behavior is confusing, as I believe I followed the grid system instructions correctly. Any thoughts?

Note: While the code functions as desired on Bootply, it fails to work on the web project I am currently developing.

PS: Bootstrap was installed via a gem, which included bootstrap_and_overrides.css.less in my stylesheets. However, my application.css file does not mention Bootstrap at all (it does not require any Bootstrap CSS files). Since installing the gem is meant to handle everything related to Bootstrap, I did not modify it. Could I be overlooking something? Should application.css require Bootstrap for proper functionality?

Answer №1

It is important to ensure that divs are nested correctly.

<div class="container-fluid">
  <div class="row">
    <div class="col-md-8"> 
      ...
    </div>
    <div class="col-md-4"> 
      ...
    </div>
  </div>
</div>

For further information, visit: http://getbootstrap.com/css/#grid

Answer №2

It dawned on me that my project was built with SASS instead of LESS, which is necessary for the twitter-bootstrap-gem. I made the switch to the bootstrap sass gem and everything is running smoothly now.

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

Align select and number inputs vertically in Firefox

How can I achieve vertical alignment for these inputs on Firefox? The alignment works perfectly in Chrome, Safari, and Opera, but not in Firefox (Version 57 tested on macOS, Windows, and Linux Mint). While removing type="number" from the input resolves th ...

The function SVGGeometryElement.isPointInFill() may not function correctly in Chromium, but it does work properly in Firefox

I'm currently working on a solution to detect when a path within an SVG file on a canvas has been clicked. The code I've written functions correctly in Firefox, but I'm encountering issues with Chromium browsers. When I surround the code wit ...

Has Apache initiated a forced logout process?

Running a LAMP server, I have implemented Apache basic authentication to log in users accessing the server homepage. I am currently seeking a way to enforce user logout, but my attempts with mod_session & mod_auth_form have not been successful. The page ...

Challenges of relative positioning with dynamic height based on content

Hello! I'm trying to achieve this https://i.stack.imgur.com/Q6lXP.png In this case, there are 3 divs. The top one will have a width of 100% and a height of auto, with relative positioning. The second div is similar, but I plan to add some dummy text ...

Utilizing jQuery to attach events to dynamically generated elements

I have a scenario where I am uploading multiple images and inserting them into specific div elements. These divs should toggle a class when clicked. Should I include the part of code that adds the onclick event inside the ajax success function? Your help i ...

Automatically submitting an HTML form from a JSP page

Encountering the same origin policy issue with Ajax, but in need of sending a form post to a different server. The question at hand is: How can I call my JSP to automatically submit a form to another server? Attempts to use an AJAX call to the JSP page h ...

Is it considered a bad practice to apply overflow: auto to all elements with the exception of html?

My approach to beginning a new design always involves overriding the default padding and margin set by the browser on all elements: * { margin: 0; padding: 0; } After coming across j08691's response regarding a margin collapse issue, I discovered th ...

Chosen link fails to update color

I've successfully implemented a navigation bar that changes the content in the body when each link is selected. Utilizing AJAX for dynamic content changing, I can change the color of menu items on hover but am facing issues with changing the color upo ...

Refresh the options in a dropdown menu after selecting a radio button using jQuery

Upon selecting either the male or female radio button, I wish to populate a list with names corresponding to the selected gender from a database. The male and female tables in the database consist of two columns: {id} and {name}. <?php include "co ...

Superimpose a form onto the array of pictures

Utilizing Bootstrap 4 for a current project <div class="container-fluid"> <div class="row"> <div class="col-lg-6"> <a class="lightbox" href="./images/bg.jpg"> <img src="{{ listing.p ...

How can I retrieve the background color of the WordPress admin page?

Is there a way in PHP to extract the current active colors of specific elements like #wpadminbar or #adminmenu .wp-submenu from the admin page for my plugin? I am not interested in getting the schema names (base, focus, current)! Here is an example code s ...

When the page is zoomed in, the Bootstrap navbar overlaps with

I'm currently in the process of developing a website that includes a navbar with a navbar-fixed-top class. Everything seems to be working perfectly except for when I zoom in. On mobile devices, when I zoom in, the navbar starts wrapping and goes to th ...

Implementing pagination in Angular Js to redirect users back to the current page without resetting to the initial page

Dealing with paging can be tricky, especially if you're fetching a large amount of data at once through a $http request. Let's say you have 50 records and you're using the following code for paging: $scope.numPerPage = 10; $scope.curren ...

Discrepancy in the vertical pattern repetition of the SVG background

When I use a simple div with an SVG set as a background image with vertical repeat, I noticed a gap of varying sizes on Chrome and Firefox depending on the screen size (please resize the window). Check out the issue here .bg { width: 50%; height: 2 ...

Is there a competitive edge in defining Css Selector with symbols versus without symbols in Selenium Test Automation?

When it comes to Test Automation, CSS is used to define page elements. There are two ways to define a sample page element: element :fld_page_element, "#uniqueID .some-class-name" OR, element :fld_page_element, "[id='uniqueID'] [class='som ...

What is the process for ensuring that the "ng-multiselect-dropdown" is a mandatory field within Angular 7?

Is there a way to require the ng-multiselect-dropdown field to have at least one selected item? <ng-multiselect-dropdown [placeholder]="'Select countries'" [data]="countries" [(ngModel)]="countriesSelectedItems" [settings]="co ...

Anticipated a JavaScript module script, but the server returned a MIME type of text/html as well as text/css. No frameworks used, just pure JavaScript

I have been attempting to implement the color-calendar plugin by following their tutorial closely. I have replicated the code from both the DEMO and documentation, shown below: // js/calendar.js import Calendar from '../node_modules/color-calendar&ap ...

How can I add an embedded record in Mongoid?

There are 2 classes in my project - Articles and Comments (which are nested within Articles). class Article include Mongoid::Document field :name, type: String field :content, type: String field :published_on, type: Date validates_presence ...

Is it possible to make a radio button readonly with Enums in C#

During the development of my ASP.Net MVC 4 application, I tried implementing a solution found on pass enum to html.radiobuttonfor MVC3, but unfortunately, I am still facing an issue. My goal is to create an edit page where the Status field is displayed as ...

Guide to creating a nested table with JavaScript

Currently, I am utilizing JavaScript to dynamically generate a table. To better explain my inquiry, here is an example of the HTML: <table id='mainTable'> <tr> <td> Row 1 Cell 1 </td> ...