Footer in Bootstrap 3 malfunctions if <h2> tag is missing

I've encountered a strange issue that I can't seem to figure out. Simply removing the <h2> tags in my code causes the footer to move to the top instead of the bottom. Oddly enough, the footer works perfectly when there is a title, but as soon as I remove it, everything goes haywire.

Take a look at my code below:

<!DOCTYPE html>
<html>
<head>
    <title>Bootstrap 101 Template</title>
    <meta content="width=device-width, initial-scale=1.0" name="viewport">
    <!-- Bootstrap -->
    <link href="inc/bootstrap.css" media="screen" rel="stylesheet">

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="../../assets/js/html5shiv.js"></script>
      <script src="../../assets/js/respond.min.js"></script>
    <![endif]-->

CSS

<style type="text/css">

    #under-header {
        height: 250px;
    }

    #screenshot {
        margin-top: -150px;
        text-align:  center;
    }

    #features {
        height: 200px;
    }

    #margin-50 {
        margin-top: 50px;
    }

    #margin-100 {
        margin-top: 50px;
    }

    /* Wrapper for page content to push down footer */
#wrap {
  min-height: 100%;
  height: auto !important;
  height: 100%;
  /* Negative indent footer by it's height */
  margin: 0 auto -60px;
}

/* Set the fixed height of the footer here */
#push,
#footer {
  height: 60px;
}

</style>

</head>

HTML

<body>
    <div class="container-fluid">
    <div id="wrap">
            <div class="row-fluid">

        <div class="col-md-10 col-md-offset-1" id="margin-100">
                <h2>Title</h2>
                <div class="well"></div>
        </div>

        <div class="col-md-10 col-md-offset-1">
                <h2>Title</h2>
                <div class="well"></div>
        </div>

        <div class="col-md-10 col-md-offset-1">
                <h2>Title</h2>
                <div class="well"></div>
        </div>

         <div class="col-md-10 col-md-offset-1">
                <h2>Title</h2>
                <div class="well text-center">
                    <p></p>
                    <a class="btn btn-primary" href="#">Link</a>
                </div>
        </div>


    </div>
<div id="push"></div>
</div></div>
    <footer id="footer">
     <div class="row-fluid">

                <h2>THIS IS IMPORTANT FOR THE FOOTER</h2>
                <div class="well text-center">
                    <p></p>
        </div>
        </div>
        </footer>
</body>
</html>

Answer №1

After reformatting it in Sublime text, I noticed an extra closing </div>. I am uncertain whether you intended to have the footer inside the main container, but this setup worked for me. I'm not very experienced with Bootstrap, however.

<!DOCTYPE html>
<html>
<head>
    <title>Bootstrap 101 Template</title>
    <meta content="width=device-width, initial-scale=1.0" name="viewport">
    <!-- Bootstrap -->
    <link href="inc/bootstrap.css" media="screen" rel="stylesheet">

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="../../assets/js/html5shiv.js"></script>
      <script src="../../assets/js/respond.min.js"></script>
    <![endif]-->

<style type="text/css">

    #under-header {
        height: 250px;
    }

    #screenshot {
        margin-top: -150px;
        text-align:  center;
    }

    #features {
        height: 200px;
    }

    #margin-50 {
        margin-top: 50px;
    }

    #margin-100 {
        margin-top: 50px;
    }

    /* Wrapper for page content to push down footer */
#wrap {
  min-height: 100%;
  height: auto !important;
  height: 100%;
  /* Negative indent footer by it's height */
  margin: 0 auto -60px;
}

/* Set the fixed height of the footer here */
#push,
#footer {
  height: 60px;
}

</style>

</head>
<body>
    <div class="container-fluid">
      <div id="wrap">
        <div class="row-fluid">

          <div class="col-md-10 col-md-offset-1" id="margin-100">
            <h2>Title</h2>
              <div class="well">
              </div>
          </div>

          <div class="col-md-10 col-md-offset-1">
            <h2>Title</h2>
            <div class="well">
            </div>
          </div>

          <div class="col-md-10 col-md-offset-1">
            <h2>Title</h2>
            <div class="well">
            </div>
          </div>

         <div class="col-md-10 col-md-offset-1">
            <h2>Title</h2>
            <div class="well text-center">
              <p>testing</p>
              <a class="btn btn-primary" href="#">Link</a>
            </div>
        </div>
      </div>
      <div id="push">
      </div>

    <footer id="footer">
    <div class="row-fluid">
      <div class="well text-center">
      <p>sdfdsdsfsd</p>
      </div>
    </div>
  </footer>
 </div>
</body>
</html>

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

Retrieving data from MongoDB and presenting it neatly in Bootstrap cards

I have successfully retrieved data from MongoDB and displayed it in Bootstrap 5 cards. However, I am facing an issue where all the cards are appearing in a single row if there are multiple entries in the database. What I want to achieve is to utilize the ...

Can you suggest a method to save cookies or HTML5 localStorage across multiple WebBrowser instances on Windows Phone?

Quick question: How can I save data from Javascript in a WebBrowser control on my Windows Phone 8 app so that it remains even after the user closes and reopens the app? In more detail: I am working on a Windows Phone 8 app with a single WebBrowser contro ...

Overflow of nested item within flex container

I'm trying to make the content under "foo" fully scrollable, but I've been unsuccessful using flexbox. I attempted it with min-height, yet it didn't work out. Check out this JSFiddle for reference $('.ui.dropdown') .dropd ...

Tips for adding a button to the SB Admin 2 Card header without altering its height

I am currently utilizing the SB Admin 2 template for my project and encountering difficulty when trying to add a button in the card header without altering the default height. The goal is to maintain a consistent look across both cards, as illustrated in t ...

What are the steps to prevent a redirect?

I have two forms with different functionalities - one for submitting/adding and the other for selecting/redirecting. Currently, both forms are redirecting. How can I prevent the top form from redirecting after submission? <?php if($_POST){ / ...

What is the best way to implement nested iterations in Jade?

ul li a(href='') menu1 li a(href='') menu2 ul li a(href='') sub-menu2 li a(href='') menu3 ul li a(href=&apos ...

AngularJS: intercepting custom 404 errors - handling responses containing URLs

Within my application, I have implemented an interceptor to handle any HTTP response errors. Here is a snippet of how it looks: var response = function(response) { if(response.config.url.indexOf('?page=') > -1) { skipException = true; ...

What is the best way to add content to a box once it has been hovered over?

Looking to create a sticky note-style design, but struggling with displaying the content inside the box only when hovered. In my code example below, can you help me achieve this effect? body { margin: 45px; } .box { display:inline-block; backgrou ...

Create CSS styles that are responsive to different screen sizes and

What is the best approach to ensure that these styles are responsive on any mobile device? nav ul ul { display: none; } nav ul li:hover > ul { display: block; } nav ul { background: #0066cc; background: linear-gradient(top, #0066cc 0%, #bbbbbb 10 ...

Is there a way in JQuery to apply the CSS of one element to another selected element?

I'm curious if there is a JQuery function available that can be used to transfer the exact CSS styles from one element to another. I want all the CSS properties to be applied without any additional inheritance. For example: <div id="d1"> &l ...

Learning the process of extracting Fast Fourier Transform (FFT) data from an audio tag within

I am struggling to retrieve the FFT data from an <audio> tag without any syntax errors. After reviewing the Web Audio API documentation, I have written a sample code snippet as follows: <audio id="aud" controls="controls" src="test.mp3"></a ...

Tips for creating responsive images when using two images stacked on top of each other:

One of my challenges with using Bootstrap is trying to place an image on top of another image. Here's the HTML code I currently have: <section id="test"> <div class="row"> <div class="imgbg"><img src="img/bg_pres.png ...

Tips for Enhancing the Appearance of a List Input Box

While on my hunt for an auto-completing text field, I stumbled across lists. <label>Bad Habit <input list="badhabits" id="habits" name="habit"/> </label> <datalist id="badhabits"> <option value="alcoholics"> <option ...

Experience the magic of playing HTML5 video within the sleek confines of an iPhone image

After coming across a similar inquiry on Stack Overflow (), I decided to create my own solution since the original answer lacked code details. The task at hand is to embed an HTML5 video within an iPhone image frame, like so: The image dimensions are 300 ...

A comprehensive guide on creating a package that combines an href link with an <li> element

I am currently using the <li> tag to display href links. The issue I am facing is that when I click on the 'box,' it does not directly link to another page. Instead, I have to click on the href link for it to redirect to another page. Is th ...

The Infinite Loop: Unveiling the En

I'm interested in creating a unique shape resembling the symbol of infinity using CSS, SVG, or Canvas. If you're unfamiliar with what an infinity symbol looks like, here's an example: https://i.stack.imgur.com/cLhBh.jpg So far, I've a ...

Incorrect data for minimal values within Google charts

Currently, I am utilizing a Google chart found at the following link: In my data set, I have significantly high values for the line chart and relatively low values for the bar chart. In order to make both types of data more easily readable, I would like t ...

Combining data inputted into a remote/modal bootstrap form and submitting it alongside the parent page form

I am trying to create a parent bootstrap page with a form that includes a dynamic modal. The modal loads an external page containing form elements and a submit button that is supposed to submit the form on the parent page. However, when I click the submit ...

The total height of the document's body in jQuery is not equal to the sum of the viewport height and the window's scroll top position at the bottom of the document

Why does the document height appear smaller than the window scroll top value plus the viewport height when I reach the end of the document? Shouldn't they be equal? I've been struggling with this issue for hours and can't seem to figure it o ...

Struggling to stack two forms on top of each other within a Bootstrap row class

I am trying to incorporate 2 forms on a web page, one below the other. Here is what I have: <body id="Signup"> <form class="row col-lg-6"> <legend>Légende</legend> <div class="form-group"> ...