使用 left: 明确定位我的图像正确放置它,但是当我删除 left: 并用 margin-left: auto 和 margin-right: auto 替换它时,它被定位在左侧。我做错了什么?
<body>
    <div id = "main_header" href="http://xxx" >
        <img id = "logo" src="logo.png"/>
        <h1 id = "main_title">Title</h1>
    </div>
    body {
        position:relative;
        background-image: url("large_background.png");
        font-family: Helvetica; 
        margin: 0;              /* Amount of negative space around the outside of the body */
        padding: 0;             /* Amount of negative space around the inside of the body */
    }
    #main_header {
        position: relative;
    }
    #logo {
        position:absolute;
        top: 5px;
        left: 140px;
        height: 50px;
        width: 50px;
    }