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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 03:11:01  来源:igfitidea点击:

How to fit in an image inside span tag?

htmlcssimage

提问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 标签。

enter image description here

在此处输入图片说明

enter image description here

在此处输入图片说明

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