html - CSS Resize images to fit in a container -
i want fit images in container different images size :
example :
1. full size in container bigger size.
2. middle in container horizontal size.
3. middle in container vertical size.
check out example link
as gautam said, need use
max-height:100%; max-width: 100%;
so can define class containers
.container { display:flex; align-items:center; justify-content:center; border:1px solid black; background-color: #ffffff; width: 50px; height: 50px; }
and class images
.maxsize { max-height:100%; max-width: 100%; }
the display:flex;
property makes container easier config, can center contents faster. can remove border
property, it's easier viewing of container edges. hope helps.
Comments
Post a Comment