Containing more than a full page of information, the footer stays fixed at the bottom of the screen, even as the user scrolls to

As I work on developing my artist website to showcase my music, I have encountered an issue with the footer placement. My goal is seemingly simple - I want a footer that always sits at the bottom of the site, just under the content/body section. There should be no white space on the left, right, or bottom. Ideally, when there is minimal content on the page, the footer will still hug the bottom of the screen. However, the challenge arises when the content extends beyond one page; instead of pushing the footer down, it remains fixed in its position, causing overlap issues with other content.

I've spent days searching through various sites and forums trying different solutions. While I've made progress by adjusting margins and positioning, this particular problem persists. Any assistance would be greatly appreciated. (For reference, I am using a Wordpress Twenty-Twelve Child Theme)

View Undesired Footer Image

View Desired Footer Image

My current thoughts on potential causes are:

  1. There might be code forcing the footer to stick to the bottom of the screen, irrespective of content amount, possibly utilizing min-height:100%. However, adding or removing this line yields no change.

  2. There could be a hierarchy issue within the HTML structure? The Twenty-Twelve theme uses #masthead, #page, #main, and #colophon elements. Some sources suggest placing the footer outside the main wrapper, which I've done without success.

  3. The problem may not lie in the footer itself but possibly in surrounding containers like #main requiring specific positioning adjustments (e.g., setting position:relative), yet this approach hasn't resolved the issue.

Provided below is the entire HTML snippet:

<body <?php body_class(); ?>>
<div id="page" class="hfeed site">
<header id="masthead" class="site-header" role="banner">

<nav id="site-navigation" class="main-navigation" role="navigation">
<button class="menu-toggle"><?php _e( 'Menu', 'twentytwelve' ); ?></button>
<a class="assistive-text" href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentytwelve' ); ?>"><?php _e( 'Skip to content', 'twentytwelve' ); ?></a>
<?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); ?>
</nav><!-- #site-navigation -->
<?php if ( get_header_image() ) : ?>
<a href="<?php echo esc_url( home_url( '/' ) ); ?>"><img src="<?php header_image(); ?>" class="header-image" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="" /></a>
<?php endif; ?>

</header><!-- #masthead -->

<div id="main" class="wrapper">

</div><!-- #page -->
</div><!-- #main .wrapper -->
<footer id="colophon" role="contentinfo">
</footer><!-- #colophon -->
<?php wp_footer(); ?>

</body>
</html>

The CSS styling for the footer is as follows:

footer {
background:url(http://kjel.ca/wp-content/uploads/2014/12/footer-img.jpeg) repeat-x bottom center;
height:100%;
width:100%;
position:absolute;
margin:0px;
padding:0px;
bottom:0px;
min-width:100%; 
}

Despite attempting commonly recommended solutions like Ryan Fait's sticky footer, I have struggled to achieve the desired outcome. As someone with limited coding expertise seeking cost-effective options, any guidance on rectifying footer placement woes would be immensely valuable. Visit my site at www.kjel.ca for further context. Thank you!

Answer №1

Give this a shot :

#colophon {
    background:url(http://kjel.ca/wp-content/uploads/2014/12/footer-img.jpeg) repeat-x bottom center;
    height:100%;
    width:100%;
    position:absolute;
    margin:0px;
    padding:0px;
    bottom:0px;
    min-width:100%; 
}

instead of

footer {
    background:url(http://kjel.ca/wp-content/uploads/2014/12/footer-img.jpeg) repeat-x bottom center;
    height:100%;
    width:100%;
    position:absolute;
    margin:0px;
    padding:0px;
    bottom:0px;
    min-width:100%; 
}

Answer №2

Exciting update, I've successfully resolved the code issue. I revamped the code for #colophon. The original code looked like this:

#colophon {
    background:url(http://kjel.ca/wp-content/uploads/2014/12/footer-img.jpeg) repeat-x bottom center;
    height:80%;
    width:100%;
    position:absolute;
    margin:0;
    padding:0;
    bottom:0;
    min-width:100%;
    min-height:1%; 
}

I made some improvements to it and now it looks like this:

#colophon {
    background: url("http://kjel.ca/wp-content/uploads/2014/12/footer-img-2.jpeg") repeat-x scroll center bottom transparent;
    height: 100%;
    position: absolute;
    width: 100%;
    background-size: 100% 448px;
}

The issue seemed to stem from the value of bottom: 0; which pushed the footer below the content with a right margin. To resolve this, I added the following code:

footer[role="contentinfo"] {
    line-height: 2;
    max-width: 100%;
    margin-top: 0;
    padding: 0px 0px;
}

Many thanks for your assistance everyone.

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 the browser is resized to smaller than the minimum width specified, the div element fails to center

I'm in the process of trying to center a div element. The div has a width of 400pt, while the body must have a minimum width of 500pt in order to leave at least a 50pt space around the div. Here is an example of my code: <html> <style> ...

How do I implement a dynamic input field in Angular 9 to retrieve data from a list or array?

I'm looking to extract all the strings from the Assignes array, which is a property of the Atm object, and populate dynamic input fields with each string. Users should be able to update or delete these strings individually. What approach can I take us ...

Removing the dividing line between columns in an Antd table: A simple step-by-step guide

Do you notice the lines dividing each table column heading in the image? I want to get rid of these lines from the table. The table component I am using is Antd table. https://ant.design/components/table#examples https://i.stack.imgur.com/Npx5G.png ...

Manipulate the lines in an HTML map and showcase the distinctions between them

I've been searching through various inquiries on this particular subject, but none have provided me with a satisfactory response. I have created a map where I've set up 4 axes using the following code: function axis() { var bounds = ...

Designing a navigation system that revolves around a central logo image

I have created a navigation bar that you can see in this image: https://i.stack.imgur.com/eT4TL.jpg Using foundation to construct a website, I have designed the nav bar in the following manner: HTML: <nav class="top-bar"> <ul> ...

Inheriting the viewBox attribute with SvgIcon

I have a collection of unique custom SVGs, each with its own distinct viewBox. First Custom SVG <svg viewBox="-4 -4 24 24"><path something/></svg> Second Custom SVG <svg viewBox="-5 -7 24 24"><path something ...

How can I showcase both a username and email address in a Material UI chip?

I'm currently using Material UI chip to show name and email next to each other. However, when the name is long, the email goes beyond the chip boundary. Here's my function that generates the chips: getGuestList() { let {guests} = this.sta ...

Tips for centering content in the middle of a line

How can I center align 3 buttons on a line using CSS and HTML? This is what I have tried so far: 1/ CSS : .center-buttons { display: flex; justify-content: center; } .button { margin: 0 10px; } 2/ HTML: <div class="row"> <di ...

Display an icon from the glyphicon library in an Angular application based on a

My Controller: .controller('BlogController', function(blogFactory, $routeParams, $scope){ var that=this; stat=false; this.checkbookmark = function(bId){ console.log(bId) blogFactory.checkBookmark(bId, function(response){ ...

Displaying the second div once the first div has loaded, then concealing the first div

Current Approach: There are two divs occupying the same space, with div1 set to display:block and div2 set to display:none When a tab is clicked, jQuery hides one div over a period of 2000ms and reveals the other div. Challenge: The goal is for the ...

Tips for transitioning from custom CSS to Material UI's CSS in JS

I came across a project where someone implemented components with custom CSS. One interesting thing I noticed was a wrapper component, similar to Material UI's Container or just a simple div with applied styles. export const Container = styled.div` ...

ID is not receiving the CSS styles

I'm having trouble applying my CSS to a specific img ID element on the page. I've been trying to solve this for about 30 minutes with no luck. The strange thing is, I have two other elements with the same HTML and CSS that are working correctly. ...

Ways to configure dynamic and responsive divs using CSS exclusively (no javascript needed)!

I am looking to have my main div expand in height based on the categories div, content, or product pictures. Check out the website here Here are the issues I'm facing: The content div and categories div are both within the main div, but the produ ...

What methods can you use to locate the CSS selector within HTML that meets certain criteria?

Is it possible to parse a given link and find CSS selectors with attributes that partially or completely match a specific keyword? For example, if the keyword is "print," I want to identify all CSS selectors in the link containing "print" in their name, id ...

PHP: Locate a class within an HTML element using a regular expression

I have a question about customizing my HTML ul menu with submenus. Specifically, I am looking to dynamically add a "first-item" class to the first item within the submenu using PHP. <ul id="menu-main" class="menu"> <li id="menu-item-68" class=" ...

Retrieving the "min, max, step, and value" variables from a plugin and passing them to the quantity box in Woocommerce using PHP

Having the Woocommerce Advanced Quantity plugin allows me to customize the min, max, increasing step quantity, and default quantity for each product. However, my new theme is not pulling these values from the plugin for the quantity box on the shop page. I ...

An exclusive execution of the JavaScript function is ensured

I have a JavaScript function that I want to execute 12 times in a row. Here's my approach: Below, you'll find a list of 12 images: <img id="img1" src=""> </img> <img id="img2" src=""> </img> <img id="img3" src=""> ...

Executing script once the DOM has completed loading

In my project, I'm dynamically generating menu items for a menu bar based on headers from external files that are imported using an XMLHttpRequest(). The menu bar is then updated as I navigate through different pages. Everything works smoothly. Each ...

Missing inkbar in Material UI tabs when using ReactJS

For some reason, the small inkbar is not appearing under this tab. I suspect it might be a css issue that I can't seem to figure out. It's possible that I'm missing something I don't know about or maybe the height of the tab is too high ...

Are cookies always included in client requests?

With every interaction between the server and browser, cookies are exchanged back and forth. However, what happens when an image is requested? <img src='myPic.jpg' /> Is the browser also sending cookies during this type of request? If i ...