Div Square, width size based on 100% height

后端 未结 7 2171
灰色年华
灰色年华 2020-12-03 15:15

I\'m trying to make a responsive square with the width size based on the (100%) height of the element. I believe it\'s impossible using only CSS.

The square width sh

7条回答
  •  天命终不由人
    2020-12-03 16:05

    You could do this with a tiny inline image. No JS, no extra files.

    .container {
      height: 150px;
      width: 100%;
      text-align: center;
      background: #acd;
    }
        	
    .square {
      display: inline-block;
      height: 100%;
      background: #691;
    }

提交回复
热议问题