1

我有一个如下页面;

<style type="text/css">
#test a{
  display: block;
  width: 150px;
  height: 50px;
  background-color: #CCCCCC;
}
</style>

<div id="test">
    <a>text text text<img src="image.jpg"></a>
</div>

我得到的结果是;

当前结果

但我想要类似的东西;

需要结果

是小提琴

有人知道如何解决这个问题吗?

4

3 回答 3

1

您可以添加vertical-align:top到图像

#test img{vertical-align:top;}

更新的小提琴

于 2012-04-05T07:36:38.897 回答
1

您好,您可以定义#test img {vertical-align:top;}

像这样

css

#test a{
  display: block;
  width: 150px;
  height: 50px;
  background-color: #CCCCCC;
}

#test img{vertical-align:top;}

HTML

<div id="test">
    <a>text text text<img src="http://i.imgur.com/VlyB1.jpg"></a>
</div>

现场演示http://jsfiddle.net/rohitazad/nPSBL/2/ ​</p>

于 2012-04-05T07:38:57.413 回答
-1

尝试添加到 CSS:

#test a {
    vertical-align: top;
}
于 2012-04-05T07:35:48.373 回答