<details>
- CSSTricks ⟩ box-sizing 
- MDN ⟩ <details> - 裡面有美化 <details> 的 CSS ♥️ 
- Slotted Nodes ⟩ Styling Slotted Content 
/* ⭐️ universal box-sizing */
*, *::before, *::after {
  box-sizing: border-box;
}
body {
  margin: 1em;
}
.fixed-width {
  width: 400px;
  padding: 1em;
}
summary {
  background-color: tomato;
}
p {
  background-color: lawngreen;
  margin: 0;
}
.reference {
  margin-top: 1em;
  background-color: deepskyblue;
}
<div class="container">
  
  <!-- ⭐️ built-in web component -->
  <details>
  
    <!--   light DOM   -->
    
    <!--   ⭐️ (built-in) named slot   -->
    <summary class="fixed-width">
      <details> (built-in component)
    </summary>
    
    <!--   ⭐️ slotted nodes (inserted into default slot)   -->
    <p class="fixed-width">
      `box-sizing` property is not automatically inherited to 
      slotted contents, you have to explicitly assign it.
    </p>
  </details>
  
  <!--  for reference only  -->
  <div class="fixed-width reference">
    width: 400px; padding: 1em;
  </div>
  
</div>Last updated
Was this helpful?