2011-10-28 237 views
0

我有3個div並排放在一個盒子裏。第三個(最右邊的)div裏面有一些按鈕。水平和垂直居中按鈕

但這些按鈕沒有自我爲中心(我的意思是爲軸心的垂直&水平方向)。看到藍色方塊應該在紅色框內居中的圖像,但他們實際上坐得太高,太離左邊太遠。

你能幫我把我的藍色按鈕水平放置在水平中心&垂直嗎?

http://i42.tinypic.com/1z18ahs.png enter image description here

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
    <title> </title> 

    <style type="text/css"> 
    <!-- 
     body { 
      text-align: center; 
      margin: 0 auto; 
      background-color: RGB(197, 155, 109); 
      font-family: "Arial", "Tahoma", Serif; 
      font-size: 17px; 
     } 

     p { margin: 0; padding: 0; } 

     #mainContent { 
      background-color: white; 
      padding-top: 30px; 
      display: block; 
      width: 980px; 
      margin: 0px auto; 
     } 

     #mainContentInner { 
      /*background-image: url(images/contentBottom.png) 0 bottom no-repeat;*/ 
      padding: 0px 20px 40px 20px; 
      display: block; 
      height: 390px; 
     } 

     #featureBar { 
      float: left; 
      width: 450px; 
     } 

     #menuBar { 
      float: left; 
      width: 450px; 
      height: 404px; 
      background-color: red; 
     } 

     .button { 
      width: 142px; 
      height: 202px; 
      cursor: pointer; cursor: hand; 
     } 

     .menuButtonRow { 
      margin: 0 auto; 
      padding: 0; 
      list-style-type: none; 
      list-style-image: none; 
     } 

     .menuButtonRow li { 
      display: inline; 
      float: left; 
      margin-left: 5px; 
     } 
    --> 
    </style> 
</head> 
<body> 

    <br/> 
    <div id="mainContent"> 
     <div id="mainContentInner"> 

      <div id="featureBar"> 
       <p style="background-color: green; width: 450px; height: 370px;"></p> 
      </div> 

      <div style="float: left; width: 20px; height: 400px; margin: 10px; background-color: RGB(172,225,250);"> 
       <p></p> 
      </div> 

      <!-- The 2 unordered lists in this div are supposed to be centred horizontally --> 
      <div id="menuBar"> 
       <ul class="menuButtonRow"> 
        <li> 
         <div class="button"> 
          <p style="background-color: blue; width: 142px; height: 190px;"></p> 
         </div> 
        </li> 
        <li> 
         <div class="button"> 
          <p style="background-color: blue; width: 142px; height: 190px;"></p> 
         </div> 
        </li> 
        <li> 
         <div class="button"> 
          <p style="background-color: blue; width: 142px; height: 190px;"></p> 
         </div> 
        </li> 
       </ul> 
       <br/> 
       <ul class="menuButtonRow"> 
        <li> 
         <div class="button"> 
          <p style="background-color: blue; width: 142px; height: 190px;"></p> 
         </div> 
        </li> 
        <li> 
         <div class="button"> 
          <p style="background-color: blue; width: 142px; height: 190px;"></p> 
         </div> 
        </li> 
        <li> 
         <div class="button"> 
          <p style="background-color: blue; width: 142px; height: 190px;"></p> 
         </div> 
        <li> 
       </ul> 
      </div> 

     </div> 
    </div> 

    <br/> 
    <br/> 

</body> 
</html> 

回答