2013-07-23 50 views
-1

我想中心一個空的元素DIV與定義的圖像在CSS中。 我想將DIV與圖像居中。中心空的DIV與圖像

這很難解釋。

這裏是現場演示http://www-kodovani.cz/test.html - 我想獲得與上述文本相同的居中元素#button。我知道元素居中,但圖像忽略它。

+1

請包括在這裏你的代碼,也許對您網站的鏈接或作爲的jsfiddle一個額外的資源。 –

回答

0

我認爲你要找的是添加「邊距:0自動;」到div元素?

.nase-portfolio { 
width: 180px; 
margin: 0 auto; 
height: 70px; 
background: url(images/button.png) no-repeat; 
} 
+0

是的,就是這樣,我很愚蠢。謝謝。 –

0

嘗試

#button { 
display: table; 
margin: 0 auto; 
text-align: center; 
}