问题描述
我有一些尺寸很大的照片,我想将它们设置为父母"的尺寸大小.如果有一次父级尺寸是1200x800,我想将照片尺寸设置为1200x800,但是我也想看到整个图片.如果我的父级尺寸为500x300,我希望图像尺寸为500x300,依此类推.
I have some photos which have big sizes, I would like to set them to the Parent's dimension size. If one time the parent dimension is 1200x800, I would like to set the photo dimensions to 1200x800, but also I would like to see the whole image. If my parent dimension is 500x300, I would like the image to be 500x300 and so on.
这甚至有可能吗?我想缩小图像或根据其父对象的尺寸对其进行扩展.
Is this even possible? I want to shrink the image or expand it according to it's parent's dimension.
谢谢!
推荐答案
所需的css属性是max-width
:
CSS
img {
max-width:100%;
}
您可以在图像周围添加一个容器,并设置overflow:hidden
以防止图像变得大于定义的宽度/高度.
You could add a container around your image and set overflow:hidden
to prevent images to get bigger than the defined width/height.
这篇关于制作适合其父尺寸的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!