How do you stretch an image to fill a
while keeping the image's aspect-ratio?

I need to make this image stretch to the maximum size possible without overflowing it's `
` or skewing the image. I can't predict the aspect-ratio of the image, so there's no way to know whether to use:
or
I can't use both (i.e. style="width: 100%; height: 100%;") because that will stretch the image to fit the `
`. The `
` has a size set by percentage of the screen, which is also unpredictable.
If you need the image to fill either height or width to the corresponding dimensions of the div, I can only think of using javascript. Is that something you are keen to explore?

以上就是How do you stretch an image to fill a

while keeping the image's aspect-ratio?的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » HTML5 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏