I have one div in another div. The inner div has margins of 0, auto to centralize it. However, I can't get it to float to the bottom without making it absolute. Is there anyway of making a relative div float to the bottom of a normal div?
相关问题
- Views base64 encoded blob in HTML with PHP
- How to get the background from multiple images by
- Is there a way to play audio on a mobile browser w
- HTML form is not sending $_POST values
- implementing html5 drag and drop photos with knock
You can do this by setting to top value to 100%.
Html
CSS
check out this fiddle here: http://jsfiddle.net/62wqufgk/
Nowadays you can simply use
display: flex
for all these alignment issues.In your case you can simply make the parent a flex, flex-direction
column
(the default is row) andjustify-content: flex-end
. The advantage of this approach is that it also works if you have multiple items in the parent.If you have multiple ones and want to have them all aligned from the beginning of the parent till the end, you can change
justify-content
to another property such asspace-between
orspace-evenly
.Without using
position: absolute
, you'd have to vertically align it.You can use
vertical-align: bottom
which, according to the docs:So, either set the outer div as an inline element, or as a
table-cell
:The only way I found, unless your content is a static-height, was to do it with jquery like so:
This will work for a column-div within a containing-div, if another column's height is larger.
It is unbelievable this simple thing is not 'built in' via a css-property (i.e. "float: bottom"), that doesn't break everything else with absolutes, etc.
Add this styling to the inner div.
See this,
CSS positioning at the bottom without absolute positioning