1
我搜索了這個,但沒有找到解決方案。 我有一個文本錨點。中心對齊在一個div內的錨文本
錨點的高度和寬度由JS上的DOM負載設置 我需要垂直和水平居中的錨內文本。
遵循許多有關居中元素的教程。他們都沒有工作。
這裏是我的html
<a href="#" class="wpsc_category_grid_item" title="Category1">
<span>Category1</span>
</a>
我的CSS
.wpsc_category_grid_item {
background: #000;
margin:1px;
float:left;
text-align: center;
display:table;
}
.wpsc_category_grid_item span{
display: table-cell;
vertical-align: middle;
width:100%;
height:100%;
color:#fff;
text-align: center;
font-weight: bold;
text-decoration: none;
}
我需要這些文本,垂直居中以及..
縱橫中心頁面上或者一些其他元素裏面? –
不是以什麼瀏覽器爲中心?它在Firefox和Chrome中顯示爲我居中http://jsfiddle.net/fYpub/ – Duopixel