Home > Article > Web Front-end > CSS DIV: relative positioning of parent DIV and absolute positioning of child DIV_html/css_WEB-ITnose
How to absolutely position a div within a div? It's very simple, just set the position attribute of the parent div to relative and the position attribute of the child div to absolute. . .
Example:
<html><body><div>xxxxx<div><div style="border:1px red solid;width:100%;height:50px;position:relative"><div style="border:1px red solid;width:20px;height:20px;position:absolute;right:0;top:0">x<div><div></body></html>
Effect: