Why is the footer appearing in the sidebar section?

I have a question that I believe may be common and already answered, but I can't seem to find the solution.

codepen

Currently, I am working on creating a simple 2 column layout. While the columns are displaying correctly, the footer ends up in the sidebar area if the content area is taller than the sidebar area. HTML:

/*  SECTIONS  */
                .section {
                clear: both;
                padding: 0px;
                margin: 0px;
                }
    
                /*  COLUMN SETUP  */
                .col {
                display: block;
                float:left;
                margin: 1% 0 1% 1.6%;
                }
                .col:first-child { margin-left: 0; }
    
    
                /*  GROUPING  */
                .group:before,
                .group:after {
                content:"";
                display:table;
                }
                .group:after {
                    clear:both;
                }
                .group {
                    zoom:1; /* For IE 6/7 */
                }
    
            
    
                /*  GRID OF THREE  */
                .span_2_of_3 {
                width: 66.1%;
                }
                .span_1_of_3 {
                width: 32.2%;
                }
    
               
                
               
    
                /*  GO FULL WIDTH AT LESS THAN 480 PIXELS */
    
                @media only screen and (max-width: 480px) {
                .col { margin: 1% 0 1% 0%;}
                .span_3_of_3, .span_2_of_3, .span_1_of_3 { width: 100%; }
                }
<html>
                <head>
                </head>
                <body>
                <div class="wrapper"> <div class="container">
                <div class="col span_2_of_3">
                <div>Sample text goes here...</div>
                </div>
                <div class="col span_1_of_3">
                Here is widget content
                </div></div></div>
                <footer>
                <div class="container">
                This is footer content
                </div>
                </footer>
                </body>
                </html>

Answer №1

Check out this link for more information!

One important detail you overlooked is closing a div tag, and don't forget to add the necessary styling for your footer section.

footer {
     clear: both;
}

Make sure to include this in your code as well.

Answer №2

Similar solution to the one presented by Sirence, but with different code:

CSS:

.group:after {
    content: "";
    clear: both;
    display: table;
}

HTML:

<html>
<head>
</head>
<body>
<div class="wrapper group">
    <div class="content">
        <div class="column large-2">
            <div>Lorem ipsum dolor sit amet.</div>
        </div>
    </div>
    <div class="sidebar column large-1">
        Widget goes here
    </div>
</div>
<footer>
    <div class="content">
        Footer content here
    </div>
</footer>
</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

Get the ability to overlay text onto an image by using jQuery for downloading

Currently, I am facing an issue with an online photo editor in my project. The problem is that I am unable to download the image after adding and editing text on it. The texts added are editable but the image cannot be downloaded after the changes. I nee ...

You can eliminate the display flex property from the MuiCollapse-wrapper

Having trouble removing the display flex property from the MuiCollapse-wrapper, I did some research and found the rule name for the wrapper in this link https://material-ui.com/api/collapse/ I have been unsuccessful in overwriting the class name wrapper t ...

Flipping through words to create dynamic text transformation

Is there a way to use Javascript to dynamically change the text in an H1 tag every 2 seconds without altering the HTML structure? For example: 1) Made for agencies... 2) Made for start-ups... 3) Made for small businesses... I want the words after "Made ...

An unidentified element is displayed as undefined

I am trying to implement a CSS change for mobile devices, but an unknown variable keeps showing up as undefined. Despite researching various tutorials and finding multiple solutions, I am struggling to grasp them as I am a novice in JavaScript and HTML. T ...

What could be causing the labels to stay stagnant while the image moves?

What could be causing the labels to remain static while the images (front and back of human anatomy) move on Galaxy S8 and iPhones? Check out the website at . Your assistance is greatly appreciated. ...

Have you ever wondered how the automatic video play on scroll feature works on Tiktok.com and YouTube shorts when using a mobile device?

My goal with React JS is to develop a website similar to Tiktok, where the video below will automatically play with sound as the user scrolls down. I attempted to set this up using window.addEventListener("scroll",...), but after looking into it further, ...

Issues with updating GetOrgChart value within jquery validator

I have been attempting to modify an element in GetOrgChart and here is what I am trying: HTML <form id="one"> <input type="text" name="aaa"> <input type="text" name="bbb"> <input type="submit" name='submitform' ...

Tips for excluding specific tags when creating an Xpath expression

My task involves writing an xpath to extract text from a specific element. The desired output is the text 1 Schools Found., excluding any text within the a tag. Although I have written an xpath for this purpose, I am unsure how to exclude or ignore the con ...

Struggles with arranging elements in the right position

Currently, I am in the process of learning CSS and working on developing a game that involves time and score. In short, here is what I aim to achieve: This is what I have so far: You can find my progress on jsFiddle: http://jsfiddle.net/yZKTE/ CSS: #b ...

Selectize Fails to Populate Options Using Ajax

ExpressJS is the platform I am using to develop a management dashboard for a community project. Right now, my main concern is integrating a modal that allows users to add new games to a database. Although I am able to fetch data remotely, I am facing diffi ...

What are some methods to customize the CSS subnavigation without changing the appearance of the main navigation

http://jsfiddle.net/uuyVY/ screenshot https://i.sstatic.net/CzUPk.png I'm attempting to configure the subnav to be white and span the entire containing div (which is 1100px wide), with only the text links displayed vertically. However, I'm stru ...

I'm having trouble adjusting the link color in my footer text while navigating Wordpress for the first time

As someone who is new to Wordpress, I am struggling with changing the link color in the footer text. Despite spending hours on it, I just can't seem to figure it out. The files I have been working with are style.css and bootstrap.min.css. I feel lik ...

Maintain consistent sidebar height as content changes dynamically

My website has a two-column layout with a sidebar and content section that are both set to equal height when the window loads and resizes. The page is designed to be responsive. To dynamically arrange blocks within the content area, I am utilizing a jQuer ...

How can I use an ajax get request to retrieve a css file from a webpage and then customize the default styles in my program?

Here is my current code snippet: HTML: <h1>Test Message</h1> Default CSS: h1{ font-size: 24px; } Jquery: $(document).ready(function(req, res){ $.ajax({ url:"example.com/test.css", type : "GET", crossDomain ...

Align the text to the left on the same line as the content

I'm trying to align text and an image on the same line, but there's some empty space at the top of the text. Is there a way to align them? <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" rel="styl ...

annoying box filled with information

Take a look at my http://jsfiddle.net/8wSzk/2/ <div class="row1"> <div> <div class="circle-menu"> </div> <p> some option </p> </div> <div> <div class="circle-menu"> </div> ...

What strategies can be used to avoid a single dangling word at the end of a line within an HTML element?

I am in the process of developing a straightforward webpage with marketing content. One aspect I find unfavorable is when a line of text stretches too long and breaks onto the next line, which is acceptable; however, it often splits in a manner where there ...

Responses were buried beneath the inquiries on the frequently asked questions page

My FAQs page is in pure HTML format. The questions are styled with the css class .pageSubtitle, and the answers have two classes: .p1 and .p2. Here's an example: <p class="pageSubtitle">Which Award should I apply for?</p> <p class="p1" ...

Image showcasing the background

I'm facing an issue with adding a background image to my project Even after trying to add it globally, the background image is not showing up on the Next.js index page. import { Inter } from 'next/font/google' const inter = Inter({ subsets: ...

Navigating the screen reader with the cursor位

Site Design Challenge I recently discovered that the master/detail design of my website is not very accessible. The main view features a column chart where each column represents a different month. Clicking on one of these columns reveals details in a nes ...