News for hackers. Stuff that matters.
Re:Sticky Footer by m0dest on Monday September 30, 2019 @01:44AM (#21112070)
Thanks for sharing this. Some folks are still using JavaScript for this, and it's unnecessary.

One nit: This isn't a "sticky" footer, and that's a good thing. I'd just call this a "bottom footer" for lack of a better term.

Sticky is used to describe an element that starts with a non-fixed (non-overlaying) position such as position:static and switches to a fixed (overlaying) position to stay visible on screen during scrolling.

https://developer.mozilla.org/en-US/docs/Web/CSS/position#st...

This is: The footer is placed at the bottom of the window or the bottom of the body, whichever is _lower_.

Sticky would be: The footer is placed at the bottom of the window or the bottom of the body, whichever is _higher_.

Re:Sticky Footer by whalesalad on Monday September 30, 2019 @09:00AM (#21114851)
FWIW most people have called this a sticky footer since the dawn of Web 2.0. Go back ten years and you’ll find posts describing the sticky footer that should be at the end of the content (if the content goes below the fold) or the bottom of the browser window, if the content doesn’t push the footer there.

I understand the point you’re arguing but at some point the thing something is called becomes it’s name.

If you want a name for your concept I’d call this a fixed-positioned footer which is explicit that it’s position is permanently fixed and won’t change. It also correlates with position: fixed.

tl;dr You’re concept of a sticky footer is different than the rest of the web development community so it’s important to realize that and not correct someone for being correct.

Re:Sticky Footer by m0dest on Monday September 30, 2019 @11:54AM (#21116707)
I get where you're coming from. I was around then too. :)

Then this happened:

https://trends.google.com/trends/explore?date=all&q=sticky%2...

The popular usage of "sticky headers" had the opposite meaning of "sticky" compared to "sticky footers." The usage of this word to refer to the header behavior won out and was formalized as position:sticky in CSS3 Layout.

The problem now is when people use "sticky footer" in the former sense, it's misinterpreted. Note the other comments on this story.

Re:Sticky Footer by hnarn on Monday September 30, 2019 @05:37AM (#21113251)
> I'd just call this a "bottom footer" for lack of a better term.

Maybe I'm introducing more confusion here, but wouldn't the term for this be "fixed"? I.e. it's fixed to the bottom of the page, regardless of the size of the window.

Re:Sticky Footer by gwillz on Monday September 30, 2019 @08:19AM (#21114483)
Well no, "fixed" is a position relative to the the viewport.

"Sticky" is like a conditional/hybrid between "fixed" and "relative".

I mean, I call this kind of footer "sticky" but it's not a great name and I can't think of anything better.

Re:Sticky Footer by plondon514 on Monday September 30, 2019 @03:25AM (#21112559)
Ironically this and (avoid 100vh on mobile web) https://chanind.github.io/javascript/2019/09/28/avoid-100vh-... are on the front page at the same time.
Re:Sticky Footer by sanderdlm on Monday September 30, 2019 @04:21AM (#21112835)
And both of these "articles" are hardly worth their title let's be honest. This sticky footer one could just be a link to the flex-grow documentation on the MDN, and it's not even a real sticky footer. The 100vh one comments on an issue that we've known about since responsive design became a thing in 2011 (2012?). Also, putting "A Better Solution: javascript" at the end of a blog post about a CSS problem is a joke.
Re:Sticky Footer by amelius on Monday September 30, 2019 @05:36AM (#21113245)
CSS is just broken. I want to use general expressions like

    height = a.height + b.height - 2*c.height
Re:Sticky Footer by kaishiro on Monday September 30, 2019 @08:38AM (#21114665)
You can!

  :root {
    --header-height: 5em;
    --container-height: 25em;
    --other-height: 2.5em;
  }

  div {
    height: calc(var(--container-height) - var(--header-height) + (var(--other-height)*2));
  }
Re:Sticky Footer by amelius on Monday September 30, 2019 @12:22PM (#21116993)
But this example uses static sizes, unlike the sticky footer problem of the article (where e.g. the window can be resized by the user).

Can CSS calc() be used with dynamic widths or heights of other elements?

Re:Sticky Footer by benmarks on Monday September 30, 2019 @04:09AM (#21112780)
This seems more like coincidence than irony.
Re:Sticky Footer by reissbaker on Monday September 30, 2019 @04:45AM (#21112960)
The irony is that this "sticky footer" CSS uses a

    min-height: 100vh
as part of achieving its effect.
Re:Sticky Footer by Silhouette on Monday September 30, 2019 @05:37AM (#21113253)
Although the article does end with a warning about cross-browser CSS being a bit more involved, and if you look at the full source code it links to, this is one of the issues it addresses.
Re:Sticky Footer by tonyedgecombe on Monday September 30, 2019 @05:04AM (#21113079)
I really hate sticky headers and footers, especially if I'm browsing on a small screened device.
Re:Sticky Footer by lucalanca on Monday September 30, 2019 @07:46AM (#21114175)
Sticky footer, in this case, is not really sticky as in "always there as you scroll". It's more like: "always at the end of the screen, even if there's not enough content".
Re:Sticky Footer by nazka on Monday September 30, 2019 @05:21AM (#21113156)
Did you open the link? I am pretty sure it's not what you are suggesting.
Re:Sticky Footer by jakelazaroff on Monday September 30, 2019 @02:25AM (#21112256)
Flexbox makes this so easy! I remember having to do some weird black magic with negative margins to make this work.

old_man_yells_at_cloud.jpg

Re:Sticky Footer by darekkay on Monday September 30, 2019 @05:00AM (#21113046)
I'm using such a "sticky" footer for a lot of my projects. At first, I was fine with a simple flexbox solution. Then I've tested this layout in IE11 (because it is known to have a lot of flexbox bugs). I've fixed it, but then I've got issues with Safari. It was this article that finally helped me solve the issue for all important browsers.
Re:Sticky Footer by cmroanirgo on Monday September 30, 2019 @03:26AM (#21112563)
> the CSS required to make this demo work cross-browser is slightly different from the CSS shown in the example above, which assumes a fully spec-compliant browser. See the comments in the source for more details.

The code: https://github.com/philipwalton/solved-by-flexbox/blob/maste...

It've been great if he'd hooked up the page with caniuse to determine the best css to use for a individual's use case. See also his own flexbugs (https://github.com/philipwalton/flexbugs), which ironically is linked directly from caniuse's 'known issues'.

Re:Sticky Footer by vim-guru on Monday September 30, 2019 @03:25AM (#21112550)
For websites this is just fine, but there's still the case with web-apps where you want the background to be the colour of that footer or header, so that overflow scrolling looks good.
Re:Sticky Footer by dstroot on Monday September 30, 2019 @09:18AM (#21115028)
The article makes it look simple. The actual code that deals with various browsers is here: https://github.com/philipwalton/solved-by-flexbox/blob/maste...
Re:Sticky Footer by rambojazz on Monday September 30, 2019 @10:33AM (#21115754)
Aren't CSS grids supposed to be the better solution for this kind of problems?
Re:Sticky Footer by f06111b2bd9b55 on Monday September 30, 2019 @01:30AM (#21112016)
Reminder that here is a neat little script that will let you remove sticky headers and footers with just a simple click:

https://alisdair.mcdiarmid.org/kill-sticky-headers/

Please just stop using stickys. They are annoying. Thanks.

Re:Sticky Footer by GlitchMr on Monday September 30, 2019 @01:37AM (#21112036)
This is different. The sticky footer as defined by the article means that the footer appears at the bottom of the document, not viewport. It has nothing to do with position: fixed.
Re:Sticky Footer by f06111b2bd9b55 on Monday September 30, 2019 @01:44AM (#21112073)
oh, okay. Nvm then.
Re:Sticky Footer by ejveen on Monday September 30, 2019 @07:19AM (#21113914)
Why not just set margin-top: auto for footer?
Re:Sticky Footer by httpsterio on Monday September 30, 2019 @07:21AM (#21113933)
If your page height is less than 100vh - footer height, the footer won't sit at the bottom of the page.
Re:Sticky Footer by tomcooks on Monday September 30, 2019 @03:27AM (#21112575)
main { min-height: cal(100% - header height - footer height) }
Re:Sticky Footer by uallo on Monday September 30, 2019 @03:32AM (#21112607)
Header/footer height is (most) often not fixed but changes depending on your screen size.
Re:Sticky Footer by tomcooks on Monday September 30, 2019 @02:42PM (#21118400)
Not necessarily true, and in that case you'd just have to update min-height to the new header/footer sizes.

Still wouldn't downvote