What causes the footer to disappear in Rails with Bootstrap?

Within my application.html.erb file, my setup is pretty standard:

<html class="h-100">

 !head, title, scripts, styles, stylesheets removed for this example here on stackoverflow!

<body class="d-flex flex-column h-100">



<!-- Dropdown Structure -->
  <header>

    <%= render 'shared/nav' %>
     <div class="container">
      <%= render partial: 'shared/message' %>
     </div>

  </header>

  <main role="main" class="flex-shrink-0">
      <%= yield %>
  </main>

   <footer class="footer mt-auto py-3">
    <div class="container">
      <h3>hello</h3>
    </div>
  </footer>
</body>

While this setup seems correct, there is an issue with the footer. Sometimes it is not visible and completely disappears when visiting a page. Strangely, on certain pages the footer is visible and appears in the developer tools as expected.

Initially, I thought an old scaffold.scss file may be causing the problem and removed it entirely, but the issue persisted. I have checked for any CSS overrides in my app.scss file but found nothing that should affect the footer's visibility.

EDIT:

Upon further investigation, it appears that the html and body elements are only 760px in height, while the main content is full width. I tried setting the height to 100%, but the issue remains. The problem seems to be related to the limited height of the pages in question.

Any thoughts on what might be causing this problem?

Answer №1

If you're facing a similar issue like mine, here's what helped me resolve it:

I discovered that some scripts were causing my footer to hide, particularly one that initializes a sticky chat bar at the bottom. To fix this, I moved all the suspicious scripts under the <%= yield %> in the main section. This simple adjustment finally allowed the footer to display properly!

Here's an updated snippet of the main section (scripts removed for simplicity):

<main role="main" class="flex-shrink-0">
      <%= yield %>

      <script></script>

  </main>

Best regards!

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

There appears to be some lingering content in the JQuery Mobile slide-out dialog box

My jQuery mobile slide out dialog box is experiencing an issue. The first time the slide out occurs, a comment box appears where users can enter comments and then submit them, followed by a "THANK YOU" message. However, when the user closes the dialog box ...

Choosing HTML elements within nested DIV tags

In the process of creating a Hangman-style game using javascript/jQuery, I encountered an issue with selecting HTML content from virtual keyboard keys : <div class="square keyboard"> <div class="content"> <div class="table"> ...

What is the best approach to transfer information from the client side to a node

I have an ejs page that looks like this: <%- include('../blocks/header', {bot, user, path}) %> <div class="row" style="min-width: 400px;"> <div class="col" style="min-width: 400px;"> <div class="card text-white mb-3" & ...

The display of table headers varies in IE7

I am experiencing an issue with a table that has headers, each containing a span element with a background image serving as a separator between the column headers. While the display looks correct on most browsers, on IE7 the separator image (which is with ...

What's preventing the buttons from shifting positions?

Having some trouble with my Minesweeper Web Game setup. My buttons are stuck in place and won't budge. Can someone help me figure out what's wrong? Here's the code snippet I've been working on (FYI, using NetBeans 8.1 IDE) HTML: <! ...

Is there a way to implement a shrinking header with a shadow effect while scrolling by utilizing Bootstrap and jQuery?

I am currently in the process of developing a website using Bootstrap 4 and jQuery. I am trying to implement a header that reduces in size and adds a shadow effect as the user scrolls down the page. Although I have written some code that is partially worki ...

Determining the position coordinates of an element in relation to the viewport using JavaScript, regardless of its relative positioning

I am currently developing a vueJs web application and I'm in need of determining the position of an element within my web app relative to the viewport itself, rather than its parent elements. I'm curious if there exists a function or property tha ...

Unusual issue: PDF content disappears upon reopening modal

I am trying to incorporate a PDF display within a Bootstrap modal. Inside the .modal-body, I have inserted the following code: <object width="1000" height="500" data="path/to/pdf" type="application/pdf"> ...

Generating a label on a leaflet map with htmltools results in a minuscule label

When creating a leaflet map, the first step is to specify the label. The code used on the Leaflet GitHub includes %>% lapply(htmltool::HTML) after the sprintf() function. However, when doing this, the label is created as type "list," which results in ...

Tips on identifying HTML email input validation using JavaScript?

Just like when you can determine whether an input element with a required attribute was successfully validated, try using the following code: if($('input[type="email"]').val() && $('input[type="email"]').val().includes('@') & ...

What is the reason that setting the margin of 0 on the body does not eliminate the margin on an h1 element?

I believe the body element should apply styles to all elements contained within it. In this scenario, I am attempting to give my h1 element a margin of 0. body { font: 15px/1.5 Arial, Helvetica, sans-serif; padding: 0; margin: 0; background ...

What is the best way to incorporate Bootstrap's datepicker into a website?

I'm currently working on an AngularJS application. Here is the code I have: <directive date="date" date-format="YYYY-MM-DD" > <input ng-model="Date" type="text"/> </directive> Is there a way to integrate an Angu ...

Include HTML tag and class inside a JavaScript code block

A dynamic button is loaded when a certain condition in the JavaScript is met. Upon loading, I want to trigger a function (ClickMe) by clicking the button. However, I'm facing difficulty connecting the function with the button in my code. In my scrip ...

menu roll-up in an upward direction

Is there a way to implement the CSS effects mentioned in this article to make the menu roll up instead of down? Learn How to Create a Menu that Rolls Up Using CSS! ...

Enhancing user interfaces with jQuery by updating DOM elements

Can anyone help me figure out how to update a webpage so it functions as a report that multiple people can contribute to? I'm using forms to collect data and want it to instantly display under the correct category headings. Currently, I'm using j ...

What is the best way to trigger a function once another one has finished executing?

After opening the modal, I am creating some functions. The RefreshBirths() function requires the motherId and fatherId which are obtained from the getDictionaryMother() and getDictionaryFather() functions (these display my mothers and fathers on the page s ...

Arranging containers in a fixed position relative to their original placement

A unique challenge presents itself in the following code. I am attempting to keep panel-right in a fixed position similar to position: relative; however, changing from position: relative to position: fixed causes it to move to the right side while the left ...

Utilizing Python's urllib and urllib2 to automatically populate web forms

My goal is to automatically submit an HTML form using both urllib2 and urllib. import urllib import urllib2 url = 'site.com/registration.php' values = {'password' : 'password', 'username': 'username& ...

Use JavaScript to load and set a background image for a div

When it comes to loading different images onto an "img" tag by printing their URLs using JavaScript and then letting CSS manipulate the content in the tag, I have a code snippet that does just that. $(window).load(function() { var randomImages = [&apo ...

Saving the data of a variable to a text file

I've developed a simple system to capture a person's First and Last name (this is the basic code, of course). But I'm interested in outputting the value of a variable to a text file. I've tried using some php, but it doesn't seem t ...