2013-03-14 184 views
0

我正在嘗試實現一個2x3網格佈局的問題。 http://johns-webdesign.com/portfolioV2/電網需要看起來像這樣:CSS 2x3網格佈局問題

X | X | X 
X | X | X 

正如你所看到的,申報單的一個似乎只是浮在網格佈局下。沒有去css表,我只是無法弄清楚如何解決這個問題。

HTML

<div id="content"> 
    <div id="metro_left"> 
     <h1 style="color: #f7a70e">Here is some of my latest work</h1> 
     <div id="latest_work_gallery"><img src="images/current_work.jpg" width="250" height="250" /> 
      <div class="image_caption"><a href="#">mX Fabrications</a></div> 
     </div> 

     <div id="latest_work_gallery"><img src="images/current_work.jpg" width="250" height="250" /> 
      <div class="image_caption"><a href="#">mX Fabrications</a></div> 
     </div> 

     <div class="content_spacer_down"></div> 

     <div id="latest_work_gallery"><img src="images/current_work.jpg" width="250" height="250" /> 
      <div class="image_caption"><a href="#">mX Fabrications</a></div> 
     </div> 

     <div id="latest_work_gallery"><img src="images/current_work.jpg" width="250" height="250" /> 
      <div class="image_caption"><a href="#">mX Fabrications</a></div> 
     </div> 

     <div id="latest_work_gallery"><img src="images/current_work.jpg" width="250" height="250" /> 
      <div class="image_caption"><a href="#">mX Fabrications</a></div> 
     </div> 

     <div id="latest_work_gallery"><img src="images/current_work.jpg" width="250" height="250" /> 
      <div class="image_caption"><a href="#">mX Fabrications</a></div> 
     </div> 

    </div> 

</div> 

CSS:

#content { 
    width:1200px; 
    height:580px; 
} 
#metro_left { 
    padding:0;margin:0;float:left; 
    width:800px; 
    height:560px; 
} 
#latest_work_gallery { 
    position:relative; 
    float:left; 
    width:250px; 
    height:250px; 
    margin:5px; 
    border:1px solid #333; 
    background-color: #f7a70e; 
} 
#latest_work_gallery:hover { 
    margin:10px; 
    -webkit-transform: scale(1.1); 
    -moz-transform: scale(1.1); 
    -ms-transform: scale(1.1); 
    -o-transform: scale(1.1); 
    transform: scale(1.1); 
    filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod='scale')alpha(opacity = 100); /*For IE 8 and less */ 
} 
.image_caption { 
    clear:both; 
    position: absolute; 
    left:0px; 
    bottom: 0; 
    padding: 5px 15px; 
    width:220px; 
    font-size: 18px; 
    line-height: 24px; 
    background-color:#56FB39; 
    opacity:0.8; 
} 
.image_caption a{color:#000;} 

我試圖切換花車,只是反映了問題。還試圖清除左,右或兩者。無砧

+0

呃。您在第二個分區之後有空格。 – 2013-03-14 20:03:02

+0

爲此,您可以使用一個已刪除的無序列表。使UL的三倍寬於LI並浮動:留在LI上。這使得這更簡單。 – 2013-03-14 20:06:19

回答

2

刪除:

<div class="content_spacer_down"></div> 
+0

,這並不能解決問題。將其刪除,然後將鼠標懸停在圖像上。 – 2013-03-14 20:16:52

+0

@EricLemos - 可能是由於CSS上懸停在#latest_work_gallery:hover上 – j08691 2013-03-14 20:28:43

0

你有兩個div,然後.content_spaver_down然後4個格。重新安排訂單。

<div id="content"> 
     <div id="metro_left"> 
      <h1 style="color: #f7a70e">Here is some of my latest work</h1> 
      <div id="latest_work_gallery"><img src="images/current_work.jpg" width="250" height="250" /> 
       <div class="image_caption"><a href="#">mX Fabrications</a></div> 
      </div> 

      <div id="latest_work_gallery"><img src="images/current_work.jpg" width="250" height="250" /> 
       <div class="image_caption"><a href="#">mX Fabrications</a></div> 
      </div> 

      <div id="latest_work_gallery"><img src="images/current_work.jpg" width="250" height="250" /> 
       <div class="image_caption"><a href="#">mX Fabrications</a></div> 
      </div> 

      <div class="content_spacer_down"></div> 

      <div id="latest_work_gallery"><img src="images/current_work.jpg" width="250" height="250" /> 
       <div class="image_caption"><a href="#">mX Fabrications</a></div> 
      </div> 

      <div id="latest_work_gallery"><img src="images/current_work.jpg" width="250" height="250" /> 
       <div class="image_caption"><a href="#">mX Fabrications</a></div> 
      </div> 

      <div id="latest_work_gallery"><img src="images/current_work.jpg" width="250" height="250" /> 
       <div class="image_caption"><a href="#">mX Fabrications</a></div> 
      </div> 



     </div> 

    </div> 
0

你已經放置了前兩個塊之後。由於它們正確地浮動,所以缺少一個塊。刪除上面的div或移動它,所以它會出現在前三個div。