search

Home  >  Q&A  >  body text

javascript - [CSS] Can CSS make the height and width of img equal?

img element:

Can we use css control to achieve:

No matter what device it is on:
The height of img is always equal to the width

習慣沉默習慣沉默2792 days ago968

reply all(2)I'll reply

  • ringa_lee

    ringa_lee2017-06-28 09:28:36

    Just let img occupy the parent container of equal width and height. There are various postures. For example:

    Link description

    reply
    0
  • 三叔

    三叔2017-06-28 09:28:36

    It’s okay to use the image as a background image, set height to 0 and padding-top to 100%.

    reply
    0
  • Cancelreply