Conflicting issue arising from the coexistence of Bootstrap container and CSS footer

I am currently working on creating a website with a footer menu. I have been using the container in my content to ensure proper alignment as I was unsure how to center it otherwise. However, when attempting to add the footer menu without using the container, I encountered an issue where the background color of the footer expanded upwards beyond the last div that did not have a container and the text would not align properly.

View Sample Image

The layout appears distorted after applying .mainbar:float:left; and .sidebar:float:right;.

HTML

    <div class="container" id="content">
      <div class="mainbar">
         <img src="img/img2.png"><br>
            <h4>Sample text.</h4>
      </div>
      <div class="sidebar">
         <a href="#"><img src="img/banner.png"></a><br>
         <a href="#"><img src="img/banner.png"></a>
      </div>
    </div>


<footer>
        <div id="fnav"">
            <ul>
                <li class="fmenu-item"><a href="#">HOME</a></li>
                <li class="fmenu-item"><a href="#">Company Info</a></li>
                <li class="fmenu-item"><a href="#">Product Info</a></li>
                <li class="fmenu-item"><a href="#">Career Opportunities</a></li>
                <li class="fmenu-item"><a href="#">News</a></li>
                <li class="fmenu-item"><a href="#">Support</a></li>
                <li class="fmenu-item"><a href="#">Contact Us</a></li>
            </ul>
        </div>
        <div class="copyright">
                COPYRIGHT © SAMPLE Template .ALL RIGHTS RESERVED.
        </div>
        </div>
</footer>

CSS

#content .mainbar{
            float: left;
            width: 736px;
}
.sidebar{
        float: right;
        width: 214px;
}
#fnav{
    font-size: 14px;
    margin-bottom: 10px;
    text-align: center;
    background: #eee;
}    
#fnav ul{
    display: flex;
    list-style: none;
    margin: auto;
    width: 1000px;
 }    
 #fnav ul li.fmenu-item {
    flex-grow: 1;
    padding: 10px 0 10px 0;
}    
#fnav ul li.fmenu-item a{
    color: #262d33;
    text-decoration: none;
}    
.copyright{
    font-size:10px;
    color:#444;
    text-align:center;
    position: relative;
    margin-bottom: 10px;
    letter-spacing: 0.1em;
}

Answer №1

Here is a solution for styling your website's footer:

footer {
    float: right;
    width: 100%;
}

Answer №2

Utilize this particular style as well to effectively address your issue.

footer {
   float: left;
   width: 100%;
}

Answer №3

Avoid using Float with Bootstrap 4. Consider the following example for better understanding.

.content-bar {
  min-height: 450px;
  background: #ddd;
}
.side-bar {
  min-height: 450px;
  background: #eee; 
}
footer {
  background: #ccc;
  margin-top: 15px;
}
<!DOCTYPE html>
<html>
<head>
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <title></title>
  <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
  <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</head>
<body>
  <header></header>
  <main>
    <section>
      <div class="container">
        <div class="row">
          <div class="col-sm-8 col-lg-9">
            <div class="content-bar">
              Mainbar
            </div>
          </div>
          <div class="col-sm-4 col-lg-3">
            <div class="side-bar">
              Sidebar
            </div>
          </div>
        </div>
      </div>
    </section>
  </main>
  <footer>
      Footer
  </footer>
</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

What is the best way to showcase nested array JSON data in an HTML Table?

https://i.stack.imgur.com/OHL0A.png I attempted to access the following link http://jsfiddle.net/jlspake/v2L1ny8r/7/ but without any success. This is my TypeScript code: var viewModel = function(data){ var self = this; self.orders = ko.observableArr ...

AngularJS allows a function to return an array value, which can be displayed in separate blocks on

Building a program that involves working with an AngularJS array. I need to showcase the elements of the AngularJS array, returned by a function, in an organized manner. Each element should be displayed correspondingly - for example, 'first' cont ...

Using JavaScript to implement scrolling functionality for an ASP.NET dropdownlist

On my website, I've created a page with multiple users, each having dropdown lists of items. The issue I encountered was that as the page grew in size and required scrolling, the dropdown lists wouldn't stay in place. Even when scrolling back up, ...

`Animate your divs with slide in and slide out effects using

Currently, I am in the process of replicating a website and facing some challenges. This site is my inspiration for the project. I have managed to create a sliding effect using CSS, making the div slide in and out from the same direction. However, I want ...

Adjust the image size in the jumbotron to fit perfectly without the need for scrolling

I'm in the process of creating a website with a prominent jumbotron section on the landing page. I am looking to adjust the height of the image within the jumbotron without cutting off any parts of the picture, and I do not want it to scroll to displa ...

Attempting to showcase the text within an <a> element on a <canvas> element while ensuring there are no noticeable visual distinctions

Imagine having this snippet of code on a webpage: elit ac <a href="http://www.ducksanddos/bh.php" id='link'>Hello world!</a> nunc Now, picture wanting to replace the <a> tag with a <canvas> element that displays the same ...

There is a space separating the slider image and the navigation bar

Having a small space between the slider image and the navigation bar is causing some issues. I've tried various solutions like minifying the code, adjusting margins, and setting line heights to zero but nothing seems to be working. One question I have ...

Using Express, Node, and JQuery to handle form submissions

I am struggling with form submissions while working on a web app using HTML, Express, and Node.js. Despite being new to these technologies, I have created a script that generates a dynamic form based on certain factors: $FormContainer.html(''); ...

Tips for Updating HTML Table Content Dynamically Using JavaScript without jQuery

I am in the process of developing a web application that requires me to dynamically change the content of an HTML table based on user input, all without relying on jQuery or any other external libraries. Adding rows to the table is not an issue for me, but ...

Unable to transfer a value from a CGI script back to an HTML form

When working with an HTML form that has a date field named cdt, I encountered the need to retain the date value when submitting data to an Oracle table through a CGI script. To achieve this, instead of using Javascript code like history.go(-1), I aimed to ...

Java - openpdf - Splitting words using hyphens

We are currently utilizing openpdf 1.3.26 template 2.1 to create PDFs from HTML and CSS. Within our coding, there is a div element styled as follows: .text-block{ display:block; text-align:justify; word-wrap: break-word; ...

Can you make two columns in CSS that are left floated and maintain their original order?

While the title may not provide much clarity, I am struggling to put into words exactly what I am trying to achieve. I have created a layout in Photoshop which I have shared below to help illustrate my goal. Essentially, I have a blog that displays my sto ...

A webpage specified with 'charset=iso-8859-1' accompanied by <!DOCTYPE HTML> is triggering a cautionary alert

After running the W3C validator on an HTML document, I discovered that using the following meta tag: <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> in conjunction with: <!DOCTYPE HTML> results in ...

The printing feature in javascript does not include the ability to print values from textboxes

I'm encountering an issue when trying to print an HTML table with textboxes that should get their values from another function. However, the preview is not showing anything. Below is the complete code: <html> <head></head> < ...

Set the position of a div element to be fixed

I am currently working on a straightforward application that requires implementing a parallax effect. Here are the methods I have experimented with so far: - Inserting an image within a div with the class parallax. - Subsequently, adding an overlay div ...

A method to ensure that inline <div> elements occupy the entire available width

The typical solution for this issue is using float, however, it does not work in my situation. I attempted to utilize flexbox and overflow:hidden for the parent element, but unfortunately, it did not resolve the issue. Currently, I am dealing with three i ...

retrieving a date from a different source and displaying it in a date

Is there a way to ensure that the date format in an input of type date always follows the dd/MM/yyyy Brazilian pattern, regardless of the computer or browser specifications? <div class="input-group input-group text-center in ...

Looking for assistance with accessing elements using the "document.getElementById" method in Javascript

Below is the code snippet I am working with: <html> <head> <script> function adjustSelection(option) { var selectList = document.getElementById("catProdAttributeItem"); if (option == 0) { ...

Creating a process to produce a random number and send it directly to an automated email

I'm currently utilizing a form builder from jqueryform.com to construct a registration form. My goal is to have each registered user assigned with a unique account number, which will be a randomly generated 6-digit number. Additionally, I want the pro ...

The height of the href is not displaying correctly when the text-decoration is disabled and it is placed next to

In my design, I have a link positioned next to an image with perfect vertical alignment. Everything looks great when the text has the standard text-decoration, centered vertically and all that. However, as soon as I remove the text-decoration, leaving the ...