2016-03-08 85 views

回答

0

你可以使用:

img 

{ 
position:relative; 
margin: 0 auto; 
clear:both; 
display: block; 
} 

或者:

.centerme { 
    position: relative; 
    clear: both; 
    margin: 0 auto; 
    width: 50%; //or any other value 
    text-align:center 
} 

樣本HTML:

<div class="centerme"> 
    <img src="#" height="200px" alt="" /> 
</div> 

<div class="centerme"> 
    <img src="#" height="200px" alt="" /> 
</div> 
+0

而如果事業部的一個是文本? –

+0

那麼你需要或者是針對div,或者更好的,在div上添加類並將圖像/文本放入div中,這是最安全和最正確的方式。將立即更新我的答案。 –

+0

這正是我所做的,仍然不起作用。 –

相關問題