为什么 image.height 大小不合适?
当我有一张 950x500 的图像并像这样输出时:
<img src="http://full/url/to/image.png" />
图像下方有一个奇怪的 3px 高度空间。当询问javascript时,它确实会说尺寸是950x503。虽然图像的大小确实是(检查多次)500。看来图像标签是这样的,如何解决这个问题?
请注意,图像还必须保持动态功能。因此,如果我将图像的宽度设置为 100%,高度将相应地调整大小。
When I have an image from 950x500 and output it like so:
<img src="http://full/url/to/image.png" />
There is a weird 3px in height space below the image. When asking javascript about it, it will indeed say the size is 950x503. While the image is really (check multiple times) 500 in size. It appears that the image tag does this how can this be fixed?
Note that the image must also remain to function dynamic. So if I were to set width of the image to 100% the height will resize accordingly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试这个而不是放置
display :block;
因为这会影响所有图像标签,虽然没有坏处,但正确的方法是这样的:Try this instead of putting
display :block;
beacuse this gonaa effect all the image tag though there is no harm, but the right way is this :没关系,答案是,将图像显示设置为块,如下所示:
Never mind, the answer is, set your image display on block like so: