如何根据屏幕尺寸调整图像 [英] How to fit an image according to screen size

查看:113
本文介绍了如何根据屏幕尺寸调整图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我们拥有2000像素宽的影像& CSS属性中的500px高度。对于1080p显示器,我如何正确配置此图像。我希望这个图像可以设置在任何屏幕尺寸上以进行响应式设计。

解决方案

:100%和高度:自动



如果您想覆盖整个父元素,那么高度:100%和宽度:100%


Let's say we have image with 2000px width & 500px height in css property. For a 1080p monitor how can I configure this image properly. I want this image to be set on any screen size for responsive design.

解决方案

if you want to keep aspect ratio then put width:100% and height:auto

if you want to cover whole parent element then height:100% and width:100%

这篇关于如何根据屏幕尺寸调整图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆