Automatically resize images with browser size using CSS

前端 未结 4 778
感情败类
感情败类 2020-11-27 12:07

I want all (or just some) of my images getting resized automatically when I resize my browser window. I\'ve found the following code - it doesn\'t do anything though.

<
4条回答
  •  囚心锁ツ
    2020-11-27 12:49

    image container

    Scaling images using the above trick only works if the container the images are in changes size.

    The #icons container uses px values for the width and height. px values don't scale when the browser is resized.

    Solutions

    Use one of the following approaches:

    1. Define the width and/or height using % values.
    2. Use a series of @media queries to set the width and height to different values based on the current screen size.

提交回复
热议问题