2015-11-30 32 views

回答

1

使用.img-responsive{ margin:0px auto}可能對你有用

+0

你知道我自己測試,但它不工作,但它的工作,可恥的是我,謝謝 –

+0

你最歡迎。 –

1

嘗試增加display: block; margin: 10px autostyle屬性。這將以div爲中心。我已經更新了演示的jsfiddle,link

<div> 
    <div style="margin-top: 10px; padding-right: 0px; padding-left: 0px;" class="col-sm-12 col-md-6 col-lg-4"> 
    <a href="#"> 
     <img style="display: block; margin: 10px auto; width:450px ; height:390px;" class="img-responsive" src="http://images.all-free-download.com/images/graphiclarge/daisy_pollen_flower_220533.jpg" /> 
    </a> 
    <h3 class="h">@item.GoodTitle</h3> 
    <h5 class="h">@item.GoodSubText</h5> 
    </div> 
</div> 

Ps。也會將heightheight: 390px更改爲height: auto以避免圖像拉伸。

1

您的圖片標籤改成這樣:

<img style="width:450px ; height:390px; display: inline" class="img-responsive" src="http://images.all-free-download.com/images/graphiclarge/daisy_pollen_flower_220533.jpg" /> 

通知我說:display: inline

4

的還有另一種方式來做到這一點:

包括類= 「中心塊」如下圖所示:

<img .. class="img-responsive center-block" src="http://images.all-free-download.com/images/graphiclarge/daisy_pollen_flower_220533.jpg" /> 

檢查小提琴:
https://jsfiddle.net/9h5rvgLc/5/