Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
            
- /css/css-position/containing-block-change-button.html - WPT Dashboard Interop Dashboard
 
 
<!doctype html>
<meta charset="utf-8">
<title>Tests that after making a button a containing block, dynamically-inserted abspos boxes still get positioned correctly</title>
<link rel="author" href="mailto:emilio@crisal.io" title="Emilio Cobos Álvarez">
<link rel="match" href="containing-block-change-button-ref.html">
<style>
  #button {
    width: 400px;
    height: 400px;
    margin: 50px;
    background-color: purple;
    border: 0;
    padding: 10px;
  }
  #button > div {
    position: absolute;
    width: 100px;
    height: 100px;
    background-color: green;
    /* Vertically centered to match in-flow button layout of the reference */
    top: 150px;
    left: 0;
  }
</style>
<button id="button"></button>
<script>
  let button = document.getElementById("button");
  button.getBoundingClientRect();
  button.style.position = "relative";
  button.getBoundingClientRect();
  button.appendChild(document.createElement("div"));
</script>