2013-08-27 65 views

回答

1

我看着小提琴,如果你做以下修改它應該工作:

/* In style sheet */ 
.center { 
    text-align:center; 
} 

#cv { 
    /* add this on top of what is there*/ 
    display:inline-block; 
} 

/* remove the absolute */ 
<div class="center"> 
    <span id="cv">CV</span> 
</div> 

Updated fiddle

+0

完美!我在右側有另一段文字,有同樣的問題,我只是用我假設的權利取代中心? – nlreturns

+0

是的,作爲一般規則(一個非常普遍的規則),添加一個外部容器來控制對齊,然後有一個內部可交互元素,在這種情況下,您的懸停按鈕。所以是文本對齊的權利將工作。如果我的答案有幫助,請不要忘記正確填寫/標記:D – Chris

+0

嘿,我已經爲div添加了一個圖像。文字與圖像一起下落到div的底部。這怎麼解決? – nlreturns

0

內含div將需要與絕對具有指定的寬度,因爲它不佔用整個屏幕。所以如果你設置它(#absolute)爲寬度:100%;它應該工作。

+0

它與現在的中間偏右對齊,而不是整個文本,而是整個div都可以平移。 – nlreturns

0

嘗試在div移動到屏幕的中心使用left

#absolute { 
    position: absolute; 
    left: 50%; 
    margin-left: -11px;/*half the width of the div*/ 
} 
+0

作品像一個魅力,唯一的問題是,它移動一點點到底部(呃?) – nlreturns