adjusting the width of the footer area

Hey there, I'm facing a little issue with my footer. I had set the width and height for it without any background color initially. But now, I'd like to make it stretch the entire width while adding a background color to it.

The challenge I'm encountering is figuring out how to fill the footer with a color that seamlessly repeats across, similar to what I did with the background of the body. Creating an image isn't ideal since the main page content doesn't have a fixed height. Additionally, I'm looking for a way to keep this example's footer at the bottom of the page.

I came across an example that demonstrates what I'm aiming for when you resize the solution on this page:

I hope this clarifies my objective. I would greatly appreciate any assistance in solving this puzzle.

Thank you in advance!

Answer №1

If you want to create this specific effect, the key is to position your footer outside of the wrapper. A great resource for achieving this is by using a sticky footer.

HTML

<div class="wrapper">
    <div class="push"></div>
</div>
<div class="footer"></div

CSS

* {
    margin: 0;
}
html, body {
    height: 100%;
}
.wrapper {
    min-height: 100%;
    height: auto !important;
    height: 100%;
    margin: 0 auto;
    margin: 0 auto -50px;
    width: 960px;
}
.footer, .push {
    height: 50px;
}

.footer {
    width: 100%;
    background: blue;
}

Check out the working example on JS Fiddle: http://jsfiddle.net/3KDYX/

Answer №2

To achieve a footer background color that extends to the full width of the window, you will need to position it outside of your mainwrapper container. Here is an example:

<div id="mainwrapper">
    <!-- Content goes here -->
</div>

<div id="footerwrapper">
    <footer>
        <!-- Footer content goes here -->
    </footer>
</div>

After that, in your CSS file:

#mainwrapper {
    width: 960px;
    margin: 0 auto;
}

#footerwrapper {
    background-color: blue; /* Add your preferred color here */
}

footer {
    width: 960px;
    margin: 0 auto;
}

Answer №3

I'm not sure about the layout you currently have in your code, but if you want a full-width footer with contents set to 960px, you can achieve this by implementing the following layout structure:

<body>
   <div id="header">

       <div class="wrapper">

       </div>

   </div>

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

       //your container with 960px width

   </div>

   <div id="footer">

       <div class="wrapper">

       </div>

   </div>
</body>
<!-- I suggested having a wrapper in the header and footer so that
     your text or links can be within a 960px width,
     while the header and footer backgrounds span the full-width
-->

For the CSS styling, you would need something like this:

body { width:100% }

#header, #footer { width:100% }

.wrapper { width:960px }

#footer { clear:both; height:100px; bottom:0; display:block; background-color:#555; }

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

Stop iPhone body scrolling when fullscreen overlay is opened

My goal is to prevent the body from scrolling when my fullscreen overlay navigation is open. I have added a class show-nav to the body with the CSS attribute overflow: hidden, which works perfectly on desktop but not on iPhones. After researching similar ...

Tabbable bootstrap with dropdown functionality

I am currently in the process of integrating Bootstrap tabs and dropdown menus using version 2.3.4 <div class="container"> <div class="navbar navbar-fixed-top"> <div class="navbar-inner"> <div class="container-fluid"> ...

What is the best way to test out CSS effects before they go live

I enjoy customizing the CSS, like the posted dates on my portfolio How can I make these changes without affecting the public view of the website? One suggestion from a forum was to use .date {visibility:hidden;} ...

You cannot link to the innerHTML containing bookmarks from a different page

Using JavaScript AJAX, I am including a file called cards.html into a parent HTML page named index.html. The included cards.html file consists of a list of cards, each containing a bookmark in the form <li id="byx-123_shapes">. However, w ...

Utilize Node.js and Cheerio to extract data from an HTML table

Having trouble converting an HTML table to JSON. HTML table structure: <div id="content"> <h1>content-information</h1> <table class="testinformation"> <thead> <tr> ...

Is it possible to personalize a select button for both iOS and Android mobile platforms?

I've implemented a dropdown on my website for the desktop version and it works fine. However, I want to replace this dropdown with a select button on iPad and iPhone, as I prefer how it looks on those devices. Is it possible to style the select butto ...

(Node Express) The style was not applied due to its MIME type ('text/html') not being a supported stylesheet MIME type, with strict MIME checking being enabled

My CSS styles are not applying because of a MIME type issue. I am using Express to serve my HTML page, but for some reason, the CSS is not being displayed correctly. I have tried various solutions, but it seems like I am missing something simple. Can someo ...

Choose from two dropdown lists to select values and then load the page

I am interested in creating a simple feature using PHP or JavaScript: It should either take the user to a post/page, or load the content of the post/page on the post/page itself (using AJAX or similar methods). The desired functionality is as follows: U ...

Update Relative Links using JQuery or JavaScript

Currently, I am employed by a company that specializes in building websites using a specific platform. We have encountered an issue related to relative URLs within this platform. The platform exclusively utilizes relative URLs and I am looking for a way t ...

Navigating through different templates in {output} with Ember

My first ember app is currently under construction, featuring CRUD operations. Here's a snippet of my index.html code: <script type = "text/x-handlebars" id = "settings"> <table> {{#each setting in controller}} <tr> < ...

RequireJs is failing to load a script based on its name

Recently, I delved into the world of RequireJs to enhance my understanding. However, I encountered a hurdle while trying to load a JavaScript dependency using its custom shortened name. Despite my efforts, I can't seem to figure out what I'm doin ...

"Exploring the World of String Slicing in JavaScript

export class PricingValues{ amount : string; } const PRICING_VALUES : PricingValues[] =[ {amount :'$10,000'},{amount :'$20,000'},{amount :'$30,000'},{amount :'$40,000'},{amount :'$50,000'} ...

Creating a unique tab spacing effect using HTML and CSS

I'm currently working on my personal website and I'm looking to create a tab-like effect (similar to word processors) for showcasing projects along with their descriptions. Here's an example layout: ReallyLong NameProject Project1 Descr ...

Using pure JavaScript, you can apply a CSS property to hide an element by setting

Is there a way to hide a <section> element in HTML using JavaScript while highlighting the text or showing it in a different way? This is the solution I have tried: document.addEventListener('click', function(){ var selected = windo ...

Toggle visibility of div elements in a list

Users have the option to either download a file by clicking on "download" or view it as a PNG in their browser by clicking "open". I found a solution on this platform for creating a show/hide toggle function. It worked well for one item, but I'm look ...

Saving filters in URL for easy bookmarking

My latest project involves developing a straightforward single-page application that allows users to sort entries by name and other attributes. What I want to achieve is a method of storing the current sorting selection (similar to PHP Get) without navig ...

Selenium - Strategies for locating objects when they lack an ID or Name

Recently, I've delved into using Selenium Webdriver for automation purposes. The particular webpage that I'm looking to automate is infused with CSS styling. My current aim is to interact with a dropdown labeled "Admin", triggering it to display ...

A plugin for creating modal video pop-ups using jQuery

I am currently experiencing an issue with a JQuery plugin I am using. Everything seems to be working fine except for the fact that the video is not loading, and I can't seem to pinpoint the cause of the problem. My goal is to display a Vimeo video on ...

Utilizing TailwindCSS justify-between without considering child dimensions

Is there a way to position child divs absolutely regardless of their size? For example, ensuring that the middle div is in the center no matter the sizes of its neighboring elements. <link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.cs ...

Code to conceal navigation bar...positioned neither at the top nor at the bottom of the scroll

As a graphic designer with some coding knowledge, I'm struggling with a particular issue... I have a traditional navigation bar that only appears when the user scrolls down a bit, which I achieved through JavaScript. However, I want this to occur onl ...