<div id="container">
  <div id="child">
    I'm 33% of my parent's width
  </div>
</div>
@import url(https://fonts.googleapis.com/css2?family=Architects+Daughter&display=swap);

:root {
  --pink: #E726B5;
  --yellow: #FFE699;
  --cream: #FBE5D6;
  --green: #70AD47;
  --red: rgb(250, 128, 114);
  --red-with-opacity: rgba(250, 128, 114, 0.3);
  --white: white;
  
  --text-shadow: 0.3px 0.3px #000000e0;
}

* {
  margin: 0;
  text-shadow: var(--text-shadow);
  font-size: 40px;
  font-family: Arial, Helvetica, sans-serif;
  font-family: 'Architects Daughter';
}

body {
  height: 100vh;
  background-color: var(--yellow);
  padding: 2rem;
}

#container {
  font-size: 32px;
  background: var(--red);
  display: inline-block;
  border: 3px dashed var(--pink);
 
  
  #child {
    background: var(--white);
    width: 33%;
  }
}




#container1 > #child {
   background: var(--white);
   width: max-content;
   margin-bottom: 120px;
   border: 3px dashed var(--pink);

   &:before {
     content: "Intrinsic child width is max content.";
     position: absolute;
     width: 230px;
     transform: translateX(-240px) translateY(20px) rotate(-20deg);
     color: grey;
     font-size: 30px;
   }

   &:after {
     content: "> > >";
     position: absolute;
     transform: translateX(-300px) translateY(95px) rotate(95deg);
     color: grey;
     font-size: 35px;
   }
}

#container2 {
  font-size: 32px;
  background: var(--cream);
  display: inline-block;
  border: 3px dashed var(--pink);
  margin-bottom: 120px;
  
  #child {
    background: var(--red-with-opacity);
    width: 100%;
    
    &:before {
      content: "The parent width is max content.";
      position: absolute;
      width: 250px;
      transform: translateX(-250px) translateY(15px) rotate(-20deg);
      color: grey;
      font-size: 30px;
    }
    
    &:after {
      content: "> > >";
      position: absolute;
      transform: translateX(-300px) translateY(95px) rotate(95deg);
      color: grey;
      font-size: 35px;
    }
  }
}

#container3 {
  font-size: 32px;
  background: var(--red);
  display: inline-block;
  border: 3px dashed var(--pink);
 
  
  #child {
    background: var(--white);
    width: 33%;
    
    &:before {
      content: "Final, child width is 33% of the parent's width (max-content).";
      position: absolute;
      width: 240px;
      transform: translateX(-260px) translateY(20px) rotate(-20deg);
      color: grey;
      font-size: 30px;
    }
  }
}
View Compiled

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.