gpt4 book ai didi

html - 图片高度和宽度被css覆盖

转载 作者:太空宇宙 更新时间:2023-11-04 09:27:16 29 4
gpt4 key购买 nike

<img src="img_forest.jpg" alt="Forest" width="600" height="400">

我的 html 正文标记中有上述行。但是此处指定的高度和宽度会被样式表中为 img 指定的高度和宽度覆盖。

为什么会这样?

最佳答案

在这一点上,您将对图像元素进行更多的样式设置widthheight 属性 最初告诉浏览器页面加载时需要在屏幕上为这些图像留出必要的空间量。

Tip: Always specify both the height and width attributes for images. If height and width are set, the space required for the image is reserved when the page is loaded. However, without these attributes, the browser does not know the size of the image, and cannot reserve the appropriate space to it. The effect will be that the page layout will change during loading (while the images load).

http://www.w3schools.com/TAgs/att_img_width.asp

关于html - 图片高度和宽度被css覆盖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41004033/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com