2014-06-11 28 views
0

我正在写一个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

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

#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

k罚款它的作品....但如何设置左右边距 – Shahanas

+0

它工作时,我设置宽度... – Shahanas

0

工作,你的CSS,尝试CSS:

margin: 0 auto; 
0

试试这个应该工作,让我知道,如果这错误[点击此处] [1]

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