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

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

    body
    {
        background-color: #000;
        text-align: center; 
        margin-top: 0px;
        margin-left: auto;
        margin-right: auto; 
    } 
    
    #content
    {
        text-align: left;
        background-color: #fff;
        margin-left: auto;
        margin-right: auto;
        margin-top: 0px;
        width: 90%;
        height: 100%;
        padding: 0px 5px 5px 5px;
    }
    

    Try this. This will work. Remove the html,body selector, you don't need that.

提交回复
热议问题