I have two divs inside another div and I want to use css to position one child div to the top right corner of the parent div and the other child div to the bottom of the parent div. I.e. I want to use absolute positioning for the two child divs, but position them relative to the parent div instead of the page. How can I do this?
Example html:
This is valid because
position:absolute
means "usetop
,right
,bottom
,left
Position yourself relative to a nearest ancestor withposition:absolute
orposition:relative
."So we let
#father
haveposition:relative
and the children haveposition:absolute
, and then usetop code> and
bottom
to locate subkeys.