2013-08-07 39 views
0

在我的網站的移動主題中,應該有一個帶有文本右側的圖片,它們都鏈接到父級菜單。然而,我無法調整文字高度(應該是在畫面的中心高度,但文字出現在圖片的底部,看到的圖片:設置文本右側的圖片,鏈接到圖片中間的同一頁面

enter image description here

(左電流,右因爲它應該是)

我現在的文件:

在HTML:

<div id="topbar"> 
//<div id="title">Über</div> 
//<div id="bluerightbutton"><a href="/m/language.html">More</a></div> 
<div id="leftnav"><a href="/m/de/futuristic-os">futuristicOS</a></div> 
</div> 

和css:

#leftnav a:before{content:url("../images/leftback.png");} 
#leftnav a:first-child{z-index:2; padding-bottom: 50%; width:auto} 
#leftnav a{z-index:3;margin-left:-4px;border-width:0 5px 0 13px;padding-right:4px;float:left} 
+0

提前感謝! –

回答

1

在CSS中,我會將文本的line-height設置爲高度值作爲圖像。這應該垂直居中在圖像上。

見琴: http://jsfiddle.net/GYatesIII/CLd4t/1/

+0

完全一樣,但圖像鏈接應在css文件中,而不是在html文件中 –

+0

下面是一個調整後的小提琴,圖像作爲a標籤的背景圖像。 http://jsfiddle.net/GyatesIII/CLd4t/7/ –

+0

非常感謝!如果可以的話,我會給你一個投票! –

0

嘗試:

#leftnav a { 
    display: table-cell; // Allows vertical-align & height 
    vertical-align: middle; 
    /* Now you can adjust height too, so do that until you're satisfied */ 
} 
+0

這調整行高,但圖像消失...當我添加圖片(#leftnav a:before {content:url(「../ images/leftback.png」);})然後文本下降再次.. –

相關問題