2014-11-14 72 views
1

我遇到了我的一個joomla網站的問題。我正在使用sobi來顯示購物中心內的商店地圖。我想讓這張地圖反應靈敏。的問題是,此圖是插入有CSS圖像:用css插入的響應式圖像

HTML:

<div id="system"> 
    <article class="item"> 
     <div class="content clearfix"> 
     <div id="plan-boutiques"> 
      <img src="..."></img> <!-- This is the points on the map not the map --> 
     </div> 
     </div> 
    </article> 
</div> 

CSS:

#plan-boutiques { 
    background: url(../images/rom/niveau.png) no-repeat; 
    position: relative; 
    display: block; 
    height: 374px; 
    width: 685px; 
    margin: 0 auto; 
    z-index: 1; 
} 

然後,當我改變寬度,圖像被裁剪,而不是調整大小這將是如果我有一個img標籤中的圖像。我無法改變這一點,圖像被添加到CSS。我希望有一種方法可以使其響應!

感謝

+2

您是否嘗試過使用'background-size:cover;'或'background-size:contains;'實驗? – chazsolo 2014-11-14 13:45:06

+0

是的我試過了,忘了提,但是我試過了,圖像被裁剪出來 – 2014-11-14 13:46:59

+1

Wop忘記了!它適用於包含!謝謝我不知道這樣的財產存在;) – 2014-11-14 13:47:55

回答

0

更改#plan-boutiques規則:

#plan-boutiques { 
    background: url(../images/rom/niveau.png) no-repeat top center/contain; 
    /* ... */ 
} 
1

爲了響應不適用任何固定和高度。不需要應用寬度和高度。以這種方式使用此寬度和高度。

#plan-boutiques > img { 
    width: 100%; 
    height: auto; 
    max-width: 685px; 
    max-height: 374px; 
} 
+0

高度自動不起作用,圖像不再顯示 – 2014-11-14 14:38:08

+0

高度:自動;不會影響顯示img。然後可能是這個div部分浮動不正確。 – 2014-11-14 14:46:48

+0

我告訴你我看到了什麼。這是一個複雜的,因爲我沒有管理所有的部分(感謝Joomla ..) – 2014-11-14 14:51:01