我有一個1387px寬的接觸條(.png)和四個相同的divs,其中包含覆蓋它的聯繫信息(電子郵件,twr,fb)。這是它應該是什麼樣子:同等空間divs - 錨定他們到背景圖像 - 不管窗口大小?
問: 我怎麼同樣的空間接觸的div也不管窗口大小的他們錨背景圖像?
結構:
<div id="footer">
<div id="contact-row">
<div class="contact">
<a class="email" href="mailto:#">email</a>
<a class="tw" href="http://twitter.com/#" target="_blank"></a>
<a class="fb" href="http://www.facebook.com/pages/#" target="_blank"></a>
</div>
...+ 3 more divs with class of "contact"
</div>
</div>
樣式:
#footer {
width: 100%;
height: 178px;
background: url('../img/contact-bg.png') no-repeat center;
position: relative;
clear: both;
}
#contact-row {
width: 100%;
height: 178px;
border: solid 1px #aaa;
text-align: center;
overflow: hidden;
margin: 0 auto 0 auto;
}
.contact {
width: 150px;
height: 25px;
border: solid 1px #ccc;
display: inline-block;
margin: 0 50px;
}
我已經嘗試了許多不同的解決方案,但沒有留栓背景圖像或適應較小的瀏覽器窗口。工作副本可以在這裏找到:aaargb!!!
我會欣賞一些新鮮的眼睛。謝謝!
試圖改變到'寬度:1387px'用'。聯繫{保證金:0 100像素;寬度:140px;}'測試出間距。當窗口被調整大小時,'.contact' divs不會保持以'#footer' bg圖像(或頁面的其餘部分)爲中心。你會有其他建議嗎? – Amie
'width:100%'是個問題。在'#contact-row'上更改爲固定像素寬度並不能解決問題,因爲它是父級,'#footer'也被設置爲'width:100%'。消除額外的div並改變爲固定的像素寬度解決了這個問題。謝謝! – Amie