2012-02-08 24 views

回答

2

使用容器上的文字對齊CSS值:

div { 
text-align: center; 
} 

而且保證金適用於每個圖像的內部:

div img { 
margin: 5px; 
} 
+0

如果您發現該答案解決了您的問題,請將其標記爲已接受[http://meta.stackexchange.com/a/5235](http://meta.stackexchange.com/a/5235) – iiz 2012-02-08 18:36:26

0

試試這個:http://jsfiddle.net/QrgGH/1/ substitue的div進行的img節點

+0

我是確定它並不重要,但我的圖像是並排的,它並不適合我:/ .divName { \t position:absolute; } .div img { \t border:4px solid #fff; \t margin:auto; \t margin-top:5px; \t位置:相對; – TJS 2012-02-08 18:08:18

+0

並排?你漂浮他們嗎?父div的寬度是多少?繼續併發布您的HTML和CSS代碼,以便我們可以看看 – zero 2012-02-08 18:14:17

+0

讓我只是說,它工作正常,當我只是文本對齊:中心;母公司。我只是不知道這是否是正確的做法。這是我的html/css: '

' '.div {0} {0} {0} {發送給朋友} text-align:center; } .div img { \t border:4px solid #fff; \t margin:auto; \t margin-top:5px; }' – TJS 2012-02-08 18:18:21

0
<div class="container"> 
    <div class="images"> 
    <img src="#" alt=""> 
    <img src="#" alt=""> 
    <img src="#" alt=""> 
    </div> 
</div> 

img{max-width: 100%; height: auto;} 
.container{text-align:center;} 
.images{margin: 5px;} 

閱讀關於塊和內聯元素的一些信息