简体   繁体   English

HTML中img的宽度和高度不起作用

[英]width and height of img in html doesn't work

my html is below. 我的html在下面。

    <img src="something" alt="" width="1px" height="1px" border="0" />

I think it shows image of 1px × 1px. 我认为它显示的图像为1px×1px。 but actually the code shows below. 但实际上代码如下所示。

 <img src="something" alt="" border="0" width="438" height="438" srcset="something?zoom=1.25&amp;resize=438%2C438&amp;" src-orig="something?resize=1%2C1&amp;" scale="1.25">

Why do I have the error? 为什么会出现错误? Why does not image of 1px × 1px show on my site? 为什么我的网站上没有显示1px×1px的图像? Please help me... 请帮我...

dont write px try this : 不要写px试试这个:

  <img src="http://lorempixel.com/output/abstract-qc-640-480-7.jpg" alt="" width="1" height="1" border="0" /> 

Actually it should also work with px . 实际上,它也应该与px So what could be the reason that your code isn't working is you are either overwriting the rule with some other CSS or javascript . 因此,您的代码无法正常工作的原因可能是您正在用其他CSSjavascript覆盖规则。 Turn off CSS and or javascript if it still isn't working and see why. 如果CSS和/或javascript仍然无法正常工作,请关闭它,然后查看原因。

See here if you have added CSS rules it will not work: 如果您已添加CSS规则,请参见此处,它将无法正常工作:

 img { width: 100%; height: 500px; } 
 <img src="http://lorempixel.com/output/abstract-qc-640-480-7.jpg" alt="" width="1" height="1" border="0" /> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM