CSS - Centering a page - then making the page 100% height

后端 未结 6 1902
名媛妹妹
名媛妹妹 2021-02-06 08:31

I\'m trying to center a page and then make it 100% in height. I have a div called \"content\" as the parent element of all elements in the HTML page. What do I need

6条回答
  •  天涯浪人
    2021-02-06 09:30

    To center content, put it inside of an element that has a fixed width (important!) and has margin: auto;

    There is no cross-browser was to make your div have 100% height unless you use javascript. If you are desperate for this functionality and are willing to use javascript, you can dynamically set the height of your content by setting it to the window height. I've never done this so I won't tell you how exactly, but it should be easy to find by googling.

提交回复
热议问题