How to fit an image inside a Bootstrap 3 div?

前端 未结 3 1612
说谎
说谎 2021-02-19 13:27

I am using a div tag in code as shown below:

3条回答
  •  [愿得一人]
    2021-02-19 14:06

    It is safe to assume that by fitting you mean covering all of the width. This is because

    1. You typically do not know the height just by using col-sm-6 or col-md-6 or col-lg-4.
    2. There is a huge probability of loss in aspect ratio of the image if you try to resize it according to your own will.

    Use for fitting the column. This will fit your image width-wise into the column and will automatically modify the height (keeping the aspect ratio in mind), so you do not have to worry about image getting illogically resized.

提交回复
热议问题