concept

Layout containment — CSS reference

Layout containment isolates internal layout and creates an independent formatting context, a stacking context and containing blocks for positioned descendants. It does not imply size or paint containment. Here the absolutely positioned child uses the contained box.

Formal Syntax & Structure

css syntaxcss
contain: layout;

Working Example

Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>layout-containment</title><style>body{margin:0}#a{padding:8px;background:rgb(232,237,241);color:rgb(0,0,0);box-sizing:border-box}#box{margin:20px;width:150px;height:100px;contain:layout}</style><body><section id="box"><div id="child" style="position:absolute;left:10px;top:5px">Child</div></section></body></html>
CSS Reference