Home  >  Article  >  Web Front-end  >  CSS DIV: relative positioning of parent DIV and absolute positioning of child DIV_html/css_WEB-ITnose

CSS DIV: relative positioning of parent DIV and absolute positioning of child DIV_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 12:27:40915browse

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:

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn