Can media queries resize based on a div element instead of the screen?

前端 未结 11 1697
[愿得一人]
[愿得一人] 2020-11-22 04:17

I would like to use media queries to resize elements based on the size of a div element they are in. I cannot use the screen size as the div is jus

11条回答
  •  故里飘歌
    2020-11-22 04:39

    For mine I did it by setting the div's max width, hence for small widget won't get affected and the large widget is resized due to the max-width style.

      // assuming your widget class is "widget"
      .widget {
        max-width: 100%;
        height: auto;
      }
    

提交回复
热议问题