Steps for designing a footer with a fixed width and transparent center gap that stays in place

Looking to create a fixed footer with a transparent gap at the center that is 100% fixed width? No scripts needed!

EXPAND THIS WAY <<< ______ FIXED WIDTH GAP ______ >>> EXPAND THIS WAY

MY OWN SOLUTION

HTML

<div id="Ftr">
        <div id="FtrL"></div>
        <div id="FtrM"></div>
        <div id="FtrR"></div>
    </div>
    

CSS

#Ftr {
        position: fixed;
        height: 115px;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 21;
    }
    #FtrL,
    #FtrR {
        position: absolute;
        bottom: 0;
        height: 100%;
        width: calc(50% - 360px);
        width: -webkit-calc(50% - 360px);
    }
    #FtrL {
        background: url('../Images/Layout/footer_left.png') repeat-x;
        left: 0;
    }
    #FtrR {
        background: url('../Images/Layout/footer_left.png') repeat-x;
        right: 0;
    }
    #FtrM {
        background: url('../Images/Layout/footer_middle.png') no-repeat;
        height: 115px;
        width: 720px;
        margin: 0 auto;
    }
    

Check out the live example here:

Answer №1

Utilizing CSS along with the advanced CSS3 calc function can be beneficial:

To set the width of side DIV elements, you can use the following CSS property:

width: calc((100% - 200px) / 2); /* supported by most browsers */
width: -webkit-calc((100% - 200px) / 2); /* works on webkit browsers like Chrome and Safari */
width: -moz-calc((100% - 200px) / 2); /* Firefox compatibility */

In this case, the fixed width of the center DIV is 200px. By using this approach, both side DIV elements will evenly fill up the remaining horizontal space. Keep in mind that this method may not work consistently across all browsers. In such cases, using JavaScript might be necessary (refer to my other answer).

DEMO

Kudos to the question author for pointing out the importance of webkit-calc.

Answer №2

<div id="footer">
  <div class="left"></div>
  <div class="right"></div>
  <div class="center"></div>
</div>


#footer {
  position: fixed; left: 0; bottom: 0; overflow: hidden; width: 100%;
}

#footer .left {
  float: left: width: 200px; height: 115px;
  background: url('../Images/Layout/footer_left.png') repeat-x;
}

#footer .right {
  float: right: width: 200px; height: 115px;
  background: url('../Images/Layout/footer_right.png') repeat-x;
}

#footer .center {
  overflow: hidden; height: 115px;
  background: url('../Images/Layout/footer_middle.png') no-repeat;
}

Answer №3

It seems like achieving your desired layout across different browsers using CSS alone may be a challenge. However, if you're open to a bit of JavaScript (don't worry, no need to beat me up for suggesting it!), I can show you how easily you can accomplish it with just a few lines of code. Check out the demo here.

HTML

<div id="FtrM">
    <div id="FtrL"></div>
    <div id="FtrC"></div>
    <div id="FtrR"></div>
</div>

CSS

#FtrM {
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 120px;
}
#FtrL, #FtrR, #FtrC {
    float: left;
    height: 100%;
}
#FtrL, #FtrR {
    width: 100px;
    background-color: black;
}

#FtrC {
    background: none;
    width: 200px;
}

JS

function calc() {
    $('#FtrL, #FtrR').width(($('#FtrM').width() - $('#FtrC').width()) / 2);
}
calc();
$(window).resize(calc);

Answer №4

Learn HTML with this example:

<div class="container">
<div class="footer">YOUR CONTENT HERE</div>
</div>

Style it with CSS:

.container {width:100%;}
.footer {margin:0 auto;width:300px;height:50px;}

This code should meet your requirements. Feel free to test it out here: http://jsfiddle.net/2Qw6D/1/

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

Unique Selector Customization

Is there a way to style all custom elements in CSS? I am looking to make custom elements default to block display (as most browsers render them inline by default) and then adjust as needed. A potential rule I have in mind is: *::custom { display: blo ...

What's the reason for the mousewheel functioning in Chrome but not in Firefox?

I am currently using CSS to enable scrolling up and down a popup page with just the mousewheel, but I'm facing an issue with it not working in FireFox. Surprisingly, it works fine in Chrome with the use of overflow-x:hidden; and overflow-y:auto; prope ...

How can I apply various textures in three.js?

Hello there! I'm diving into the world of threejs and currently working on a block game similar to Minecraft. Instead of relying solely on objects, I've decided to build my program using planes (specifically the PlaneGeometry class). As I wrap ...

Is it possible for a user to chat on Whatsapp by entering their mobile number in an HTML form within the app?

<?php require_once('./database.php'); if(isset($_REQUEST['submit1'])) { $number = $_REQUEST['whatsappnumber']; $code = $_REQUEST['countorycode']; $sql = "INSERT INTO whatsapp (whatsappnumber,counto ...

Unable to halt animation at the final frame

I'm attempting to implement a character jumping animation that should stop on the last frame, but it's not working as expected. I have tried using animation-fill-mode: forwards; but it didn't produce the desired outcome. Below is the c ...

The slides on SlickJS are initially loaded in a vertical alignment, but once the arrows are interacted with,

I've put together a demonstration that highlights the issue I'm facing. Upon visiting the contact section, you'll notice that all the slickJS slides are stacked vertically initially, but once you interact with them by clicking on the arrow o ...

Is it possible to utilize viewport height as a trigger for classes in Gatsby?

Unique Case Working on a Gatsby site with Tailwind CSS has brought to light an interesting challenge regarding different types of content. While the blog pages fill the entire viewport and offer scrolling options for overflowing content, other pages with ...

Issues with the FacebookConnect plugin on PhoneGap Build

Just getting started with PhoneGap build and attempting to create a simple app with a Facebook login button. The documentation for PhoneGap build makes it seem easy to add this plugin. index.html <!DOCTYPE html> <html> <head> <met ...

store the id of each li element dynamically into an array

In my code, a list is generated dynamically and each list item has a special id. I am trying to store each li "id" in one array. This is JavaScript code: var i = 0; $("ul#portfolio li").each(function(eval) { var idd = new Array(); idd[i] = $(this ...

Utilizing Print Styles in an Angular 7 Application: A Step-by-Step Guide

I'm trying to print an html form within my Angular7 App with minimal margins. I've attempted different solutions such as adjusting the margins manually in Chrome's print preview box and adding @media print styles & @page styles in both the c ...

Resolving the issue of the 'Failed to load resource: net::ERR_FILE_NOT_FOUND' error

I'm encountering issues with loading my CSS in different browsers when using the "Copy Path" feature in VSCode. While everything displays correctly in preview mode within VS, none of the styles appear when pasting the path into Chrome or Edge. Below ...

Deactivate input areas while choosing an option from a dropdown menu in HTML

I've been working on creating a form and have everything set up so far. However, I'm looking to disable certain fields when selecting an option from a dropdown list. For instance, if the "within company" option is selected for my transaction typ ...

How can I ensure my md-sidenav takes up the entire height when using ui-router?

Currently, I am utilizing the most recent version of Angular Material (1.0.0) library and I am attempting to ensure that my <md-sidebar> panel occupies the entire height of the available space on the webpage. While it functions correctly on a regul ...

Why isn't Freichat displaying the name of the user who logged in?

After creating my own small social networking site, I decided to add a chat script called freichat. However, I am facing an issue where when a user logs in, their name appears as "Guest102" instead of their actual name. I am quite confused by this problem ...

Problems with CSS text scrolling

We have a client who wants a marquee-style scrolling text banner, and I tried using CSS animations to achieve it. However, I encountered some quirks that I'm struggling to fix. If you want to take a look at the issue, here is the link: https://jsfidd ...

Troubleshooting Problem with React Slider: Inability to Display Images and Previous Button

I'm currently grappling with a React issue after following a tutorial on YouTube. I've been working in CodeSandbox and have encountered a problem where the images and previous button are not displaying as expected. Despite my efforts to debug, th ...

Attributes required are not functional on mobile devices

Good day! I have encountered an issue with the required attribute on a form on my website. It seems to be working perfectly on my browser, but not on mobile devices. Has anyone else experienced difficulties with jQuery, JavaScript, or Node packages? <f ...

How to transfer a PHP echo value to a popup modal box

I am currently developing a web backend for a restaurant that includes functionality to block or unblock restaurant owners. I have implemented an "if" condition to display a button (a tag) based on the status of the restaurant owner. My goal is to pass the ...

Is there a way to verify if text was generated using CSS?

I am working with the following HTML structure: <h4 id="myModalLabel"></h4> In my CSS, I have set the content dynamically using the following code: #myModalLabel::after { content: "gebeurtenis"; } For a live example, you can check out t ...

Establishing a connection between Python and MySQL on a Windows operating system using

Here is the source code I am working with: import pymysql import socket conn = pymysql.connect(host='127.0.0.1', unix_socket='/tmp/mysql.sock', user='user', passwd=None, db='extractor') cur = conn.cursor() cur.execu ...