How do I position an image at the bottom of div?

后端 未结 3 812
粉色の甜心
粉色の甜心 2020-12-05 06:17

I want an html image to be flush with the bottom of a div tag. I can\'t seem to find a way to accomplish this.

Here is my HTML:

3条回答
  •  天命终不由人
    2020-12-05 06:55

    Add relative positioning to the wrapping div tag, then absolutely position the image within it like this:

    CSS:

    .div-wrapper {
        position: relative;
        height: 300px;
        width: 300px;
    }
    
    .div-wrapper img {
        position: absolute;
        left: 0;
        bottom: 0;
    }
    

    HTML:

    Now the image sits at the bottom of the div.

提交回复
热议问题