Develop a custom Bootstrap layout featuring a responsive design, a sticky footer, and two rows

I am currently working on implementing a new bootstrap "frame" template for my website's layout. While setting up the navbar was relatively easy, I'm encountering some challenges with the footer.

The requirements for the footer are as follows:

  • It needs to be sticky
  • It should consist of 2 rows:
    • A thick gray row with 4 columns of responsive content
    • A thin black row that extends to the very bottom of the browser window

Here is what I have implemented so far:

sticky-footer.css:

html {
    position: relative;
    min-height: 100%;
}

body {
    margin-bottom: 550px;
}

.footer {
    background: black;
    position: absolute;
    bottom: 0;
    width: 100%;
}
// CSS code continued...

index.html:

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    // HTML code continued...
  </head>
  <body>

    <header>
      <div class="container">
        // Header content
      </div>
    </header>

    <div class="container">
      <div class="mt-1">
        // Main content
      </div>
    </div>

    <footer class="footer">
      <div id="contentFooter">
        <div class="container">
          // Footer content
        </div>
      </div>
      <div class="container" id="copyrightFooter">
        <div class="row">
          // Copyright details
        </div>
      </div>
    </footer>

  </body>
</html>

While this setup almost works as intended, there are still 3 issues remaining (refer to screenshot):

  1. There is a white space below the black part of the footer when the browser window width is narrow. The black section should extend to the absolute bottom of the viewport.
  2. The "ACME Inc." text in the black footer should be centered once responsiveness kicks in.
  3. The footer height is fixed at 550px in the body styling. Is there a way to make this dynamic so that manual adjustments are not needed?

Screenshot of current issues

Unfortunately, I couldn't provide a runnable code snippet due to limitations in the Stack Overflow editor. You can view and test the code on JSFiddle here.

Answer №1

My issue arises when the browser image is narrowed enough for the responsive style to kick in, resulting in a white stripe appearing below the black part of the footer. I am looking to have the black part extend all the way down to the absolute bottom of the browser window.

To address smaller viewports, it's important to define columns that vary based on window size. For example, your divs should be structured like this:

<div class="container" id="copyrightFooter">
    <div class="row">
      <div class="col-3 col-md-3">
        <small class="text-muted">ACME Inc.</small>
      </div>
      <div class="col-6 col-md-6">
        <a href="#" id="backToTopLink"></a>
      </div>
    </div>
  </div>

This setup will maintain relative widths similar to big screens. To make a column span the whole row, simply set it to:

<div class="col-12 col-md-3"></div>

My goal is to center the text "ACME Inc." within the black footer once the responsive design kicks in.

You can achieve this by implementing CSS targeting specific screen widths using Media queries.

For instance, if you want to center the text on small screens, consider the following code block:

@media screen and (max-width: 992px)
{
   .some-css-class{
      text-align: center;
   }
}

This styling will only affect screens with a viewport width less than or equal to 992px.

Similarly, you can handle the issue concerning defining body margins dynamically for different viewport sizes using Media queries as well.

Here is an updated fiddle pertaining to this question.

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

When bsg_head(); is inserted into the <head> tag, the content mysteriously vanishes

While working on a Wordpress project, I encountered an issue where adding the code <?php bsg_head(); ?> to the header resulted in all the content disappearing from the page. Surprisingly, the background color change from the stylesheet was still b ...

Scrolling horizontally in ng-grid version 2.0.11

In my application, I am utilizing a ng-grid with auto height and width. The challenge arises when dynamically adding columns to the grid. If there are too many columns to display, instead of showing a horizontal scrollbar, the columns shrink in size and ap ...

Looking for advice on using media queries to resize my background image - any tips?

I'm struggling to resize my background image using media queries. Can anyone offer suggestions or solutions? I've tried applying the media query for my background image like I do with other elements, and it's not working properly. The issue ...

How can one appropriately utilize the counter() function in conjunction with nested headings and corresponding counter-increment() and counter-reset() methods?

I am encountering an issue with counter-reset() when introducing a div between the initial declaration and the reset. Initially, I had structured my code like this, with headings directly under the numberedHeadings class: Now, there is a need to wrap eac ...

Enabling the "visible overflow" feature in my animation

Apologies if the terminology in this question is not quite on point - I'm struggling to find the right words. I've got a collection of circular divs styled with CSS, displayed in a row. When these circles are clicked from left to right, they ani ...

What could be the reason for JavaScript code successfully exporting to Excel using the old office extension .xls but encountering issues when trying to export

I am currently working on exporting an HTML table to Excel using JavaScript. I have encountered an issue where it does not export to the newer version of Excel with the xlsx extension. However, it works fine and exports to older versions of Excel with the ...

What is the best way to display or hide specific tables depending on the button chosen?

Being fairly new to JavaScript, I find myself unsure of my actions in this realm. I've successfully implemented functionality for three links that toggle visibility between different tables. However, my ideal scenario would involve clicking one link t ...

Steps for deploying an ejs website with winscp

I have developed a Node.js web application using ExpressJS, with the main file being app.js. Now I need to publish this website on a domain using WinSCP. However, WinSCP requires an index.html file as the starting point for publishing the site. Is there ...

In CSS3, utilize the calc() function to vertically center elements using viewport height (vh) and viewport

One of the most common cases involves using vh for setting the height of a div, and using vm for adjusting font size. Using CSS3 div.outer { height: 20vh; } div.inner { font-size: 3vw; height: auto; } div.inner2 { font-size: 2vw; } HTML - Scenario 1 <d ...

``To utilize the ng-class variable within a controller, one can simply assign the desired

How can I change the color of a div to green using AngularJs when a file is selected? html <div class="text-arrow" ng-class="{activeBackground:applyActive}">File Selection<span class="arrow-div"></span></div> css .activeBack ...

CSS table row border displaying irregularly in Chrome and Internet Explorer

I recently created a basic table with bottom row borders. Surprisingly, the borders display perfectly in Firefox but only partially in Chrome and IE 10: <div style="display:table; border-collapse: collapse; width: 100%"> <div style="display:table ...

Guide on how to toggle disabled input text box upon checking checkbox using JavaScript

When the checkbox next to the appended text box is checked, I want to disable that text box. The hard-coded text box is already disabled when its checkbox is checked. You can see the actual outcome by running the code snippet or check out the screenshots b ...

Add bullet points to the events listed in fullcalendar

Currently, I am implementing the 'fullcalendar' plugin from jquery in order to display events for a specific month. I am interested in adding bullets to the events, however, my online search did not yield any relevant results. Although I am awar ...

Simple steps to emphasize a table cell in Angular 2

Essentially, I have a table structured as shown below <table> <tr> <td>Date</td> <td>Time</td> <tr> <table> The goal is to make both the date and time clickable within this table. When clicking on the date, ...

Text displayed in a pop-up when hovering

I'm in search of suggestions for creating a text pop-up that displays when the mouse hovers over specific text. After researching numerous websites, I haven't found exactly what I need. Currently, I have a table with headers at the top and I woul ...

Can someone guide me on how to make a Carousel responsive using Angular?

HTML: <div class="voxel-row"> <div class="voxel-col-4"><h2 id="vagas_recentes">vagas recentes</h2></div> </div> <div id="carouselExampleControls" cl ...

Setting up the frontend and backend with Apache HTTP Server

I am still exploring the world of web development and trying to grasp the inner workings of it all. Currently, I have a remote Debian server with the domain www.example.com. This server hosts a java application running as a daemon process on port 4321. Ad ...

Deactivate Link Using CSS while Allowing Title to be Functional

Is there a way to enable the link in CSS while still showing the title? Take a look at my code: CSS and HTML Code: .disabledLink { pointer-events: none; opacity: 0.6; cursor: default; } <a href="www.google.com" class="disableLink" title="M ...

Harvesting information from an HTML table

I have a table displaying the following values: turn-right Go straight turn-left How can I extract only the 2nd value, "Go straight"? Here is the code snippet I tried: var text = $('#personDataTable tr:first td:first').text(); The code above ...

Develop a novel function

I am working on a new Order page where users can select a category, then a service, and fill out the quantity field for their order. I have an idea to create a function using @if and @else statements. In this function, I want to display the quantity fiel ...