将文本精确放置在图像旁边

时间:2013-02-12 04:39:22

标签: html css html5 css3

我试图将文本正好放在图像旁边的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>

1 个答案:

答案 0 :(得分: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>