2015-02-07 54 views
2

我在我的HTML代碼如下面的代碼更img標籤,img標籤寬度高度問題在Firefox

<div id="container" > 
    <div> 
     <img alt="Image1" id="Image1" src="" width="130px" height="90px" class="img"> 
     <input type="file" id="files1" class="fileUpload" name="files1[]" style="display:none" value="Select Image"> 
     <br> 
     <br> 
     <img alt="Image2" id="Image2" src="" width="130px" height="90px" class="img"> 
     <input type="file" id="files2" class="fileUpload" name="files1[]" style="display:none" value="Select Image"> 
     <br> 
     <br> 
     <img alt="Image3" id="Image3" src="" width="130px" height="90px" class="img"> 
     <input type="file" id="files3" class="fileUpload" name="files1[]" style="display:none" value="Select Image"> 
     <br> 
     <br> 
     <img alt="Image4" id="Image4" src="" width="130px" height="90px" class="img"> 
     <input type="file" id="files4" class="fileUpload" name="files1[]" style="display:none" value="Select Image"> 
     <br> 
     <br> 
     <img alt="Image5" id="Image5" src="" width="130px" height="90px" class="img"> 
     <input type="file" id="files5" class="fileUpload" name="files1[]" style="display:none" value="Select Image"> 
     <br> 
     <br> 
    </div> 
</div> 

更新時間:

MyCSSsoFar.css

#container { 
    width: 600px; 
} 

#container div { 
    float: left; 
    height: 300px; 
    width: 300px; 
} 

當我運行這個在鉻上其寬度如下圖所示,

enter image description here

但是,當我在Firefox上運行其不與原單寬度和高度像下面的圖像顯示,

enter image description here

我想在所有browser.How其寬度和高度類似鍍鉻顯示解決這個問題?

+0

請問你的CSS看起來像那麼遠? – pbaldauf 2015-02-07 11:05:25

+0

嘗試加上'''' – 2015-02-07 11:06:55

+0

@pbaldauf現在檢查我的問題。 – MMMMS 2015-02-07 11:08:34

回答

2

我認爲你缺少你的img -elements的display: block財產。默認情況下,瀏覽器將添加display: inline

img { 
    border: 1px solid red; 
    display: block; 
} 

這是一個快速的Fiddle

+0

其工作正常。感謝您的解釋。 – MMMMS 2015-02-07 11:17:52

1

添加下面的CSS:

.img{ 
    display:block; 
    border:1px solid; 
} 

檢查小提琴這裏:Fiddle

+0

謝謝你的迴應! – MMMMS 2015-02-07 11:19:29

1

繼承人是一個選擇,如果你想顯示默認破碎圖像圖標(這也解決您的問題)

img{ 
    -moz-force-broken-image-icon:1; 
}