| <!DOCTYPE html> |
| <!-- |
| | It should be possible to have children inside an inline-block box that |
| | both define and depend on the width of the parent box. |
| --> |
| <html> |
| <head> |
| <style> |
| body { |
| margin: 0px; |
| color: #fff; |
| font-family: Roboto; |
| font-size: 50px; |
| font-weight: bold; |
| } |
| .inline-block { |
| background-color: #2196f3; |
| display: inline-block; |
| } |
| .percentage-width { |
| background-color: #3f51b5; |
| height: 50px; |
| width: 50%; |
| } |
| .spacer { |
| height: 5px; |
| } |
| </style> |
| </head> |
| <body> |
| <div> |
| <div class="inline-block"> |
| <span>Hi!</span> |
| <div class="percentage-width"></div> |
| </div> |
| </div> |
| |
| <div class="spacer"></div> |
| |
| <div> |
| <div class="inline-block"> |
| <span>Hi</span> |
| <div class="percentage-width">there!</div> |
| </div> |
| </div> |
| </body> |
| </html> |