fit the image
2022年5月1日小于 1 分钟
fit the image
Question
Suppose we have following image of ratio 1:4
![](data:image/svg+xml,%3Csvg viewBox='0 0 320 80' xmlns='http://www.w3.org/2000/svg'%3E%3Cstyle%3E .text %7B font: 60px sans-serif; fill: %23fff; %7D %3C/style%3E%3Crect width='100%25' height='100%25' fill='%23f44336' /%3E%3Ctext x='50' y='60' class='text'%3EBFE.dev%3C/text%3E%3C/svg%3E)
Now in an HTML structure like below, please fit the image to the container div, just as if it is used as container's background-image with background-size:cover
.
<div>
<img class="image" src="..."/>
</div>