Div Square, width size based on 100% height

后端 未结 7 2175
灰色年华
灰色年华 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-03 15:58

    Ok here the solution.

    test
    $(window).ready(updateWidth); $(window).resize(updateWidth); function updateWidth() { var square = $('#square'); var size = square.height(); square.css('width',size); }

    http://jsfiddle.net/j372H/7/

提交回复
热议问题