How can I position my div at the bottom of its container?

前端 未结 24 2473
广开言路
广开言路 2020-11-22 00:46

Given the following HTML:



        
24条回答
  •  星月不相逢
    2020-11-22 01:30

    Using the translateY and top property

    Just set element child to position: relative and than move it top: 100% (that's the 100% height of the parent) and stick to bottom of parent by transform: translateY(-100%) (that's -100% of the height of the child).

    BenefitS

    • you do not take the element from the page flow
    • it is dynamic

    But still just workaround :(

    .copyright{
       position: relative;
       top: 100%;
       transform: translateY(-100%);
    }
    

    Don't forget prefixes for the older browser.

提交回复
热议问题