2013-02-12 68 views
0

我試圖把文本DIV(水平)正好中間圖像的旁邊,它必須可以點擊放置文本正中央旁邊的圖像

下面是代碼,我想那麼遠,

<!DOCTYPE html> 
<html lang="en"> 
<head> 
    <style> 
    #div { 
    width: 128px; 
    height: 35px; 
    border: 2px solid #ccc; 
    } 
    </style> 
<body> 
<div id="div">Some service 
<a href="http://stackoverflow.com"> 
<img src="http://upload.wikimedia.org/wikipedia/commons/1/1a/Volkswagen_Logo.png" alt="Stack Overflow" width="40" height="35"title="Click to return to Stack Overflow homepage" /> 
</a> 
</div> 
</body> 
</html> 

Am trying to do like this image

解決方案:

<!DOCTYPE html> 
<html lang="en"> 
<head> 
<style> 
#div { 
width: 128px; 
height: 35px; 
border: 2px solid #ccc; 
} 
</style> 
<body> 
<div id="div">sdasdasdasd 
<a href="http://stackoverflow.com"> 
    <img src="http://upload.wikimedia.org/wikipedia/commons/1/1a/Volkswagen_Logo.png" alt="Stack Overflow" width="40" height="35"title="Click to return to Stack Overflow homepage" style="vertical-align:middle"" /> 
</a> 
</div> 
</body> 
</html> 
+0

完全重複:http://stackoverflow.com/questions/489340/how-do-i-vertically-align-text-next-to-an-image-with-css – 2013-02-12 04:45:09

+0

這是HTTP: //jsfiddle.net/SYxcX/你需要什麼? – coder 2013-02-12 04:47:21

+0

謝謝兄弟,我知道了 – EnterJQ 2013-02-12 04:47:54

回答

0

我想這就是你需要? DEMO

<div id="div"> 
<a href="http://stackoverflow.com">Some service 
<img src="http://upload.wikimedia.org/wikipedia/commons/1/1a/Volkswagen_Logo.png" alt="Stack Overflow" width="40" height="35"title="Click to return to Stack Overflow homepage" /> 
</a> 
</div>