0

This is for a footer containing three child items. By footer I mean an element of content-determined height with its base being the base of its own container, occupying the entire width of its own container.

The width and height of the child items are dynamically determined and varying.

The height of the footer element should be the height of its largest child item.

The first item should be left justified in the footer. The second item should be centralized within the footer, i.e. its center should be the horizontal midpoint of the container. The third item should be right justified within the footer.

The vertical alignment of the three items should be consistent. It would be good to have a choice of any of all three tops aligned, all three bases aligned and all three (vertical) centers aligned.

My struggle is with achieving the horizontal centralization of the second item. My expectation was that with display: grid on the footer I could achieve this using justify-self:start on the first child, justify-self:center on the second child and justify-self:end on the third child. What happens is that the first element justifies left as I expect, the final element justifies right as I expect, but the center element doesn't centralize in the container, instead it presents with equal space on the left and on the right. This is central if the left and right elements happen to be the same size, but they almost never are.

It seems that justify-self:center doesn't centralize in the container, but in the space between the left and right items.

This use case seems quite commonplace and reasonable to me, so no doubt there is a straightforward way to achieve it, but I don't see a way at least in pure CSS. Can anyone advise please?

Iain MacKay
  • 319
  • 3
  • 7
  • Whats wrong where is your Code?, and please Provide a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) – unkown53 Nov 06 '20 at 12:00
  • The question was asking for such an example, there was no impaired solution to correct! I hope the description given is full and sufficient to specify the problem and I believe meets the Stack Overflow criteria. – Iain MacKay Nov 08 '20 at 13:54
  • Fortunately, Stack Overflow has directed me to a very similar question https://stackoverflow.com/questions/55393088/align-3-unequal-blocks-left-center-and-right which had several partial answers, including one which made me realise the problem is tractable using CSS grid. I have posted a solution with complete example there. – Iain MacKay Nov 08 '20 at 13:56

0 Answers0