如何保持原始图像比例?
如果我有一个“img”元素并且我做“style="width: 25px; height: auto;""图像没有自动高度,它被修改了。如何获得自动高度?
最佳答案
img
标记的 width
和 height
属性默认执行此操作。
<img width="100" src="https://images.unsplash.com/photo-1562939230-e05e7c80c1d5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=652&q=80" />
<hr />
<img width="25" src="https://images.unsplash.com/photo-1562939230-e05e7c80c1d5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=652&q=80" />
关于html - 如何保持原始图像比例?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57012527/