CSS Zoom to Fit height and width (Stretch)

前端 未结 2 2042
旧巷少年郎
旧巷少年郎 2021-02-08 04:15

My content is in a container of 800x480 pixels. When the window resizes, my goal is to:

  • Zoom/Stretch the container to fill the entire screen
  • Including all
2条回答
  •  -上瘾入骨i
    2021-02-08 04:45

    You can't zoom independently width and height but you can simulate the zoom effect with the CSS scale property that you can apply independently to X and Y axis :

    transform: scaleX(2) scaleY(1.5);
    

    DEMO

    Don't forget to specify a transform origin to 0 0 so that the top/left of your element isn't cropped by the viewport.

提交回复
热议问题