自动对齐不起作用

时间:2014-06-11 04:05:37

标签: html css

我正在编写一个PHP页面,但是当我调整浏览器大小时,div元素不会移动。 即

       <html>
            <head>
                <style>
                    body{background-color: #CDD3FA}

                    #paragraph {
                        margin-right: 300px;
                        margin-left: 300px;
                        width: 720px;
                        border: 1px solid #a1a1a1; 
                        padding: 10px 40px; 
                        background: #E0E2EE; 
                        border-radius: 25px;
                        text-align: justify;

                    }
        </style>

            </head>
            <body>
              <div id="paragraph">
                        <p><strong> Note: Application for TAC approval is similar, but not identical, to Section II of the Institutional Ethics Committee Application Form. As far as possible, the total length of the TAC application, with the responses, should not exceed six pages or 2500 words. Use of simple language is preferred. Ensure that full forms or definitions of all abbreviations and acronyms are given. The investigator should ensure that sufficient information is provided to show that the study is scientifically sound and technically feasible, and that the expected outcome of the study is clearly defined. If the sub-sections A to H are not sufficient to provide these aspects of the research, additional details of the study should be provided in sub-section I.</strong></p>
        </div>

    </body>
</html>

当我调整页面大小时,如何修复居中?

3 个答案:

答案 0 :(得分:3)

试试这个(更新代码和小提琴)

 #paragraph {
                    margin: 0 auto;
                    width: 300px;
                    border: 1px solid #a1a1a1; 
                    padding: 10px 40px; 
                    background: #E0E2EE; 
                    border-radius: 25px;
                    text-align: justify;

                }

Working Fiddle

答案 1 :(得分:0)

使用你的css,试试css:

margin: 0 auto;

答案 2 :(得分:0)

尝试这个应该可以工作,让我知道这是不是[点击这里] [1]

[1]: http://jsfiddle.net/9sLdV/1/