Html 如何适应span标签内的图像?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27427073/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to fit in an image inside span tag?
提问by kumareloaded
I have an image inside a span tag. But the problem is the image doesn't fit inside the span tag. Instead a part of the image goes out of the span tag.
我在 span 标签中有一个图像。但问题是图像不适合跨度标签。相反,图像的一部分超出了 span 标签。
<span style="padding-right:3px; padding-top: 3px;">
<img class="manImg" src="images/ico_mandatory.gif"></img>
</span>
I want to have that bar inside the span i.e It should be adjacent to the text box.
我想在跨度内有那个栏,即它应该与文本框相邻。
How can I achieve it?
我怎样才能实现它?
回答by WebbySmart
Try this.
尝试这个。
<span style="padding-right:3px; padding-top: 3px; display:inline-block;">
<img class="manImg" src="images/ico_mandatory.gif"></img>
</span>
回答by Sookie Singh
Try using a div tag and block for span!
尝试使用 div 标签并阻止跨度!
<div>
<span style="padding-right:3px; padding-top: 3px; display:block;">
<img class="manImg" src="images/ico_mandatory.gif"></img>
</span>
</div>