[英]Centralize vertically a text and an image inside a <a> element
My simple HTML: 我简单的HTML:
<a>
<span>My Text</span>
<img src="" width="50" height="50" />
</a>
My CSS: 我的CSS:
a {
padding: 6px;
}
Fiddler: http://jsfiddle.net/sa3LT/ 提琴手: http : //jsfiddle.net/sa3LT/
Hi everybody!! 大家好!!
I'm having a trouble with this question. 我遇到了这个问题。 Is simple, I think, but for me I don't find a resolution for this problem.
我认为很简单,但对我来说,我找不到解决这个问题的方法。
Tks for all. Tks for all。
It sounds like you want the text in the a
tag to be vertically centered next to the image. 这听起来像你想在文本
a
标签垂直居中图片旁边。 Adding this bit of CSS will solve the issue (and as pointed out from Smeegs, this CSS will be for all img
tags inside an a
block: 添加这一点CSS将解决问题(正如Smeegs所指出的,这个CSS将用于
a
块内的所有img
标签:
a img {
vertical-align: middle;
}
JSFiddle : http://jsfiddle.net/sa3LT/1/ JSFiddle : http : //jsfiddle.net/sa3LT/1/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.