2014-05-07 37 views
0

在關於標題「數字工匠」我有一個文本塊和浮動旁邊給它的圖像三個滑動部分在我的投資組合(http://www.samnorris.co.nz)第..如何正確居中/浮動這些圖像?

我的網站是爲了響應,所以在較小屏幕尺寸的情況下,本節中的佈局旨在將文本塊上面的圖像(較小尺寸版本)移動到文本塊上方,並且理想情況下是居中。

我很難讓這些圖像以較小的屏幕尺寸爲中心,但是,在@media屏幕和(最大寬度:320px)例如它們都在這個地方,margin:0 auto似乎是完全沒有任何影響浮點或顯示設置的任何組合我嘗試過......在平板電腦尺寸@media屏幕和(最小寬度:500px)和(最大寬度:900px)我已經管理了一種僞中心通過玩弄利潤率不均勻,但並不是很理想......

有什麼我在這裏失蹤?有沒有更簡單的方法來做到這一點?

相關CSS

.about-featureimg { 
    display: block; 
    float: right; 
} 

.lionhead { 
    background: url("../img/lionhead.jpg") no-repeat center;  
    width: 455px; 
    height: 400px; 
    margin: 0 0 15px 45px; 
    display: block; 
    float: right; 
} 

.astroslinger { 
    background: url("../img/astroslinger.gif") no-repeat center;  
    background-size: cover; 
    min-width: 500px; 
    height: 425px; 
    margin: 10px 0 15px 45px; 
} 

.spacedude { 
    background: url("../img/spacedude.jpg") no-repeat center; 
    width: 545px; 
    height: 455px; 
    margin: 10px 0 25px 75px;  
} 

媒體查詢例子

.about-featureimg { 
    display: block; 
    margin: 0 auto; 
} 

.astroslinger { 
    background: url("../img/astroslinger-sm.jpg") no-repeat center;  
    width: 325px; 
    height: 220px; 
    margin: 25px 15px 25px 15px; 
} 

.lionhead { 
    background: url("../img/lionhead-sm.jpg") no-repeat center;  
    width: 290px; 
    height: 300px; 
    margin: 0 auto; 
} 

.spacedude { 
    background: url("../img/spacedude-sm.jpg") no-repeat center;  
    width: 376px; 
    height: 257px; 
    margin: 0 auto; 
} 

我的意思視覺例子,這在一定程度上居中,但不完全:

enter image description here

這一個是不是在所有中心:

enter image description here

+0

哎呀,修復了一個防止頁面正常加載的錯誤> _ < – FuManchuNZ

回答

1

嘗試的圖像的寬度設置爲100%,爲小的媒體的查詢。這爲Chrome中的元素集中了我(並將測試推到了下面)。希望這可以幫助。

+0

嗯,謝謝你沒有想到,它的工作原理雖然奇怪,但第一個圖像雖然.... – FuManchuNZ

0

嘗試將圖像的邊距設置爲自動,或者如果仍然不能正常工作,請將其設置爲父級文本 - 居中對齊。

+0

我的歉意,忘了提及我對於那個特殊的圖像有一個雜散的最小寬度聲明,它正在破壞事物,'現在你的原始解決方案工作得很好。再次感謝! – FuManchuNZ