Horizontal and vertical centering above a sticky footer in CSS

后端 未结 2 1032
遥遥无期
遥遥无期 2021-02-15 12:54

Given a sticky footer such as that on Ryan Fait\'s site with a fixed pixel height, is it possible to center, both horizontally and vertically, variable-size content in the space

2条回答
  •  一向
    一向 (楼主)
    2021-02-15 13:19

    I would suggest looking at Bobby van der Sluis's article on Footers at A List Apart.

    Example #7 at the end of his article shows a vertically centered block. It does rely on scripting, but it is truly minimal.

    edit You can also use a single-cell table to accomplish vertical centering. Incorporating it with Ryan Fait's sticky footer would give you something like this:

    
    
    
        
    
    
    
    

    Vertically Centered!

    This block will remain centered. Just needs that one table cell wrapping.

提交回复
热议问题