CSS - 文本和图像链接文本垂直对齐中间
答
演示:http://jsfiddle.net/Blender/sVx5e/1/
HTML:
<div onclick="window.location = '#'">
<img src="http://doc.jsfiddle.net/_images/jsfiddle-logo-thumb1.png">
jsFiddle
</div>
CSS:
div {
height: 150px; /* This is the height of the image */
line-height: 150px;
}
img {
float: left;
}
使用<div>
,而不是一个<a>
元件,包装元件的块时。 IE呛起来,当你做...
非常好,谢谢!但是我确实使用了''元素。我只是设置了'display:block;'就可以了。感谢您的理念! – 2011-05-02 18:10:21
IE浏览器无法正常使用块'a'元素... – Blender 2011-05-02 18:14:11
它在IE8中为我工作。您能否发布支持您的声明的源代码:“IE无法正常使用块”“元素。” – 2011-05-02 20:54:24