Footer stuck at the middle

Hello,
I’m using wordpress but I know some of CSS and HTML aswell.
So I decided to edit some stuff that I can handle using the CSS.
So, the footer came with the wordpress didn’t stick to the button, I tried to stick it and it did work, but somehow when there’s lots of content when u have to scroll down, the footer stays at the middle of the content, but in a weird way.
My code is simple as that -

footer {
position:absolute;
bottom:0;
width:100%;
height:100px;
}

Before scrolling down - https://i.gyazo.com/db07f56490f485d69f54655d4dd50c5a.jpg
After scrolling down - https://gyazo.com/e752866260641bb7274c95340c83d75e

On other pages which has less content that doesn’t needs to scroll, it is at the button.

Thanks.

The first image, the footer is at the button, its just the image isnt at the full size of the screen so it has white additions.

Hi,

That would place the footer at the botom of its nearest positioned parent/ancestor, if not other set it will be the html/viewport and then it will be stuck there.

Normally that would usually be a 100% high main div that has taken its 100% min-height from body and html, so all of those needs the hight:100% setting. Then how to make the footer sticky depends on if the footer is a child of the body or a child of the main container. Here is an old method:

html,
body{
   margin:0;
   padding:0;
   height:100%;
}
main{
    position:relative; /* this makes the main the nearest positioned ancestor to the AP footer. */
    padding-bottom:100px; /* protects the content from the overlapping footer. */
    min-height:100%; /* it will overflow the body when more content fills up. So the scrollbar is the normal on the root element.  */
}
footer{ 
   position:absolute; /* This is a footer that is contained by a positioned main container */
   bottom:0;
   width:100%;
   height:100px;
}
footer{       /* This is a footer that is a sibling coming after a non positiond main container */
   margin-top:-100px; /* pulls up the footer to ovewrlap the 100px main padding. */
   height:100px;
}

There are more robust demos at @PaulOB’s site: http://www.pmob.co.uk/
You will find lots of demos to learn from, after all he is the guy who invented the sticky footer and never stopped developing. Look for his latest sticky footer technique using css table display.

Hey,
It didnt fix it, it’s the same as it was…
I really tried almost everything I could and couldn’t find an answer for it.

My post was an attempt to explain how a sticky footer works with a link to working demos, not to suggest a solution.

You gave very little info in your first post, nothing at all to draw any conclusion from. The screenshots said nothing useful.

Please post the whole code you have so we can see what’s wrong. If possible you can also upload the whole page to your host in a temporary directory and link to it.

As it is a WP site you perhaps could obfuscate the address like: www_wpdomain_com so we can type the address and take a look.

I guess you are working with a “child theme” to make the changes, otherwise the changes will be gone after the next theme update.

Ohh alright.
Well idk how I can give you the whole code but the website is maszone.com maybe it helps?

Good! The absolute positioned footer will refer its bottom position to the nearest ancestor that has position set. Like I told in the explanation I posted.

Your footer takes its postion refering to the viewport because that is the ultimate ancestor, the html element has as default a position (the stacking starts there).

I think you could have figured out the solution if you gave it a thorough thought.

The page has a #wrapper div that is the parent to the footer and it need to get position applied to it so the footer refer to that div and not the html.

Try add this rule set and see what happen:

#wrapper { 
   position: relative; 
}

Nope it doesnt fixes using the relative to the wrapper.
I still don’t get the issue tbh xd.

Why did you change the footer position:absolute to position:fixed?

Please explain in detail how you want the footer to behave!

I changed it to not leave it bugged as it is right now, it’s just a temporary solution for me.

My goal is to stick it at the button at any page any time… and it just doesn’t work.

By ‘button’ do you actually mean bottom ?

Using position:fixed will keep the footer at the bottom of the viewport at all times. However it means that the last element on the page will be obscured by the fixed footer and you won’t be able to see the last 120px or so that is hidden behind the footer.

The usual solutio is to add some padding bottom to the container that matches the footer height.

e.g.

.wide #wrapper.container,
#wrapper.container  {
    padding: 0 0 120px!important;
}

(I don’t know why you are using !important on the padding but I left it in place anyway.)

Of course if the footer wraps at smaller screens then the height of the footer changes so you will need to use media queries to take care of that. Generally fixed footers are best for small footers with little content.

A ‘sticky footer’ is one that generally sits at the bottom of the viewport when there is little content but sits at the bottom of the document if content is greater than the viewport (although the term ‘sticky’ is now currently associated with elements that move and then stick so is a little confusing working out the jargon :))

Then it is a “sticky footer” you want, the link I posted has many demos of that kind.

Please try my suggestion exactly as it is written, and set the footer position back to absolute when you try this.

I’ll give you a rule-set for the #wrapper again, this time with a bottom padding to avoid overlap of content by the absolute positioned footer.

.wide #wrapper.container { 
   position: relative; 
   padding-bottom: 120px !important;
}

If that doesn’t work as I said, then I have no solution to your problem. Though, in that case I will test to edit your page in my browser to be sure it works.

EDIT)
@PaulOB, you actually understood the question I think, it make sense, but I didn’t notice the post until now. Wish the thread end wasn’t covered by the post editor, I’ll never learn to scroll and check before posting.

1 Like

Nope… sadly it didn’t really fix it.
It’s all same and I’m just out of ideas and motivation to fix it haha.

It’s stuck at the bottom of the content right now but if there’s less content then it just stucks at the middle of the page(under the content)…

Must be some problems with the body / wrapper or something like that.

Sorry for double posting but I thought that if I disable the footer at certain pages that would be awesome.
Is there any way to do that? Like to disable footer showing up at “store” or “faq” pages etc?
I mean, I mostly need at at the home page only… I could live without it for now at the other pages.

You didn’t answer my question and you are saying different things each time so its hard to guess what you want?

I’m assuming now that you want a sticky footer as I gave you the code for a fixed footer already. A sticky footer is one that stays at the bottom of the viewport on small pages but at the bottom of the document on tall pages (unlike a fixed footer which stays at the bottom of the viewport at all times).

Add this code after all your original code and test and see if it is what you meant. I can’t guarantee that this code will work on all pages if you have a different structure and you will need to test to make sure there are no adverse side effects.

html, body {
	margin:0;
	padding:0;
	height:100%;
}
.wide #wrapper.container, #wrapper.container {
	position: relative;
	padding-bottom:0!important;
	display:table;
	width:100%;
	height:100%;
}
#wrapper:after {
	display:none
}
footer {
	position:static;
	display:table-row;
	height:1px;
}

Retro-fitting a sticky footer is never the best approach as its best to start with the right simple structure from the get go.

1 Like

Well I’m sorry but yes my main goal is to make the footer sticky at the button of every page no matter what.
But still it didn’t fix it but it made it even lower than it was. You can see at the website - maszone.com
Somewhy a scroll-bar came up and made the page even longer on a short and not needed for scroll pages with your code, dunno why.

Please read my posts otherwise I can’t help you I’m afraid as I have given you everything you need so far.

I still don’t know what a ‘button’ is yet it was my first question to you?

Do you mean bottom?

Please read my posts.

I gave you a sticky footer and all that a sticky footer entails and as explained in my post. It is working as expected for a sticky footer.

On long pages like your home page the footer will be at the bottom of the document (i.e. after all the content in the normal flow of the document).

However you now seem to be asking for a fixed positioned footer so please re-read post #11 which explains all that you need to do.

e.g.

Add position:fixed to the footer and pad out the bottom of the main container.

Remove the code I gave you before and do this:

.wide #wrapper.container,
#wrapper.container {
position: relative;
padding-bottom:120px!important;
}
.footerclass{
position:fixed;
bottom:0;
width:100%;
height:auto;
z-index:99;
}

All the code I have given you so far has been tested and working so please don’t reply “It doesn’t work” because it does work.:slight_smile: If it doesn’t work as you expected then please explain what you wanted to happen and why this does not meet your requirements. You now have the code for all variations so the answer is in this thread.

Remember in order for us to help you you have to be clear and unambiguous in the discussions.:slight_smile:

3 Likes

I’m sorry, I dunno why but I seem to use button instead of bottom every damn time.
Yes, I meant bottom and no, I don’t want a fixed one.
By saying sticky I meant to stick at the bottom of the screen even of there’s a scroll needed on big pages such as my homepage.
As you could see at my home page, it’s perfect, at the others you could see it’s not at the very bottom of the page, it just goes under the content.

Which browser are you using, @Minnow, and which OS? I’ve checked on Firefox and Chromium on Ubuntu and both show the same thing.

On your home page, which is long and requires scrolling, the footer is positioned at the end of the page.

On your other pages, where the content does not fill the screen (on my 1280px x 1024px monitor), the footer is positioned at the bottom of the screen.

Is this not what you are seeing?

Oh really, nope, I’m using Chrome atm and I see the same as you do only at the home page.
Pages such as store and cart, the footer isn’t at the bottom of the page, it’s at the bottom of the content which isn’t too much at those pages.