How to align an image to the bottom of the div?
- Trying to align an image to the bottom of the out div element using vertical-align,but this vertical-align doesn’t seem to work,the image is not moving at all.
- We are using bootstrap classes for alignments. Is there anything that can make the image div align to the bottom of the outer div?Which is taking the height of second div which is 300px;.
- something like this should do the trick:
- You could add those classes to the DIV and the IMG respectively.
- It looks like the parent div will be 300px high anyway because of the height set on the child in the adjacent div. If you specify the height of the parent instead, then you can absolutely position the child relative to the size of the parent.
- If you don’t set the parent as position:relative, then the child will be position relative to something else (like the page).
- Vertical-align won’t work because the IMG is an inline element, and the behavior you’re expecting is table-cell dependent.
- With inline elements, vertical alignment is relative to the line and not to the parent container, so that an image aligned with text would sit in various positions relative to a given line of text.
- Using display: table-cell is fine, provided that you’re aware that it won’t work in IE6/7
- To fix the space at the bottom, add vertical-align: bottom to the actual imgs:
- There’s always the most obvious fix, which is to simply remove the whitespace in the HTML:
- To this:
- Flexboxes can accomplish this by using align-items: flex-end; flex-direction: column; with display: flex; or display: inline-flex;
< div > with some proportions :
< img >’s with their own proportions :
[ad type=”banner”]