how to align img inside the div to the right?

前端 未结 6 1527
滥情空心
滥情空心 2021-02-03 20:31

I would like to know how to align the image inside the div on the right side?

6条回答
  •  北荒
    北荒 (楼主)
    2021-02-03 21:02

    You can give the surrounding div a

    text-align: right
    

    this will leave white space to the left of the image. (= the image will occupy the whole line).

    If you want content to be shown to the left hand side of the image, use

    float: right
    

    on the image. However, the surrounding div will then need overflow: auto to stretch to the needed height.

提交回复
热议问题