我试图将文本恰好位于div的中间位置(水平)在image旁边,并且它必须是可点击的

下面是代码,到目前为止我尝试过...

<!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>




解决方案:

<!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>

最佳答案

我认为这就是您所需要的? 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>

10-05 21:10