2013-09-23 28 views
-1

我在將「#offer」分隔在「.tight」部分中出現問題。我不想用「位置:絕對的」因爲在1024像素寬度的屏幕中可以正確顯示網站。置中部分

這裏的HTML:

<section class="main"> 
    <section class="tight"> 
     <div id="offers"> 
     <article class="offer"> 
      <div id="offer_stats"></div> 
      text 
     </article> 
     <article class="offer"> 
      <div id="offer_comp"></div> 
      text 
     </article> 
     <article class="offer last"> 
      <div id="offer_time"></div> 
      text 
     </article> 
     </div> 
    </section> 
</section> 

而CSS:

section.main { 
    min-width: 880px; 
    max-width: 1200px; 
    margin: 0 auto; 
} 
section.tight { 
    width: 100%; 
    margin: 0 auto; 
    float: left; 
} 
#offers { 
    float: left; 
    padding-bottom: 100px; 
    text-align: center; 
} 
article.offer { 
    float: left; 
    min-height: 178px; 
    width: 260px; 
    color: #59535e; 
    padding-right: 50px; 
} 
article.offer.last { 
    padding-right: 0; 
} 
article.offer div { 
    height: 178px; 
} 
#offer_stats { 
    background: url("../images/offer_stats.png") no-repeat; 
} 
#offer_comp { 
    background: url("../images/offer_comp.png") no-repeat; 
} 
#offer_time { 
    background: url("../images/offer_time.png") no-repeat; 
} 

的PRINTSCREEN: enter image description here

有什麼建議?

回答

2
section.main { 
    width: 880px; 
    max-width: 1200px; 
    margin: 0 auto; 
} 
+0

這不是解決方案,因爲我想在1200px寬度中顯示其餘的元素默認值。 – MuchaZ

+0

你想讓我使用jQuery解決方案嗎?因爲你不能以'min'&'max'寬度居中元素。 – mdesdev

1

首先,我建議你從#offers

#offers { 
    padding-bottom: 100px; 
    text-align: center; 
} 

二去除float: left;,我建議你使用display: inline-block;代替float: left;article.offer

article.offer { 
    display: inline-block; 
    min-height: 178px; 
    width: 260px; 
    color: #59535e; 
    padding-right: 50px; 
} 

看到這個jsfiddle

+0

對於小提琴中的堆棧溢出標誌+1 – professorfish