How do I center a container in my HTML/CSS?

前端 未结 2 1305
我在风中等你
我在风中等你 2021-01-15 23:22

I have developed a website as part of my assignment. As I am new to html/css I could not figure some problems out of my code. The assignment specifications says that the scr

相关标签:
2条回答
  • 2021-01-15 23:50

    Jsfiddle: http://jsfiddle.net/2gtsK/show/

    Removed width from body, Added margin:0 auto to #box

    margin:0 auto is same as:

    margin-top: 0;
    margin-right: auto;
    margin-bottom: 0;
    margin-left: auto;
    

    .

    body
    {
        height: 750px;
        margin: 2px;
        padding: 2px;
    }
    
    
    #box 
    {
        width: 1000px;
        margin: 0 auto;
        height:100%;
        border:1px solid #8D8D8D;
    }
    
    0 讨论(0)
  • 2021-01-16 00:03

    You can wrap it by another div and set that div's text-align:center;

    0 讨论(0)
提交回复
热议问题