Place square svg to the center of the screen, scale it to fit the screen's width and height with some constraints

后端 未结 6 1432
臣服心动
臣服心动 2021-02-14 14:03

It seem to be a silly question and possibly a dupe, but I couldn\'t find a good solution for a while, so finally dare to ask.

I want to place an

6条回答
  •  逝去的感伤
    2021-02-14 15:05

    Try this css:

    #picture {
      transform: translate(-50%, -50%);
      top: 50%;
      left: 50%;
      position: absolute;
      max-height:15cm;
      max-width:15cm;
      width: 80%;
      height: 80%;
    }
    

    here is the result: https://jsfiddle.net/twe9jfkf/

    is this what you try to achieve?

提交回复
热议问题