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

后端 未结 6 1903
名媛妹妹
名媛妹妹 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

    This works for me in Firefox 3 & Safari 3. Don't have access to IE.

    html{
      position:absolute;
      top:0;
      bottom:-1px;
      left:0;
      right:0;
      height:100%;
      text-align:center;
    }
    body{
      text-align:left;
      margin-left:auto;
      margin-right:auto;
      margin-top:0;
      min-height:100%;
      min-width:30em;
      max-width:50em;
      width:expression("40em");/*IE doesn't support max/min width*/
      padding:0 1em 0 1em;
    }
    

提交回复
热议问题