philipwalton / flexbugs

A community-curated list of flexbox issues and cross-browser workarounds for them.
MIT License
13.63k stars 495 forks source link

column flex: wrong width on automatically resized img #286

Open Pestdoktor opened 3 years ago

Pestdoktor commented 3 years ago

Similar to Flexbug#14: same workaround, different symptom

<!DOCTYPE html>
<html>
  <head>
    <style>
      .flex {
        display: inline-flex;
        flex-direction: column;
        background: red;
        height: 150px;
      }

      .content {
        min-height: 0;
      }

      img {
        width: auto;
        height: 100%;
      }

      .flex-fix {
        flex-direction: initial;
        writing-mode: vertical-lr;
      }

      .flex-fix > * {
        writing-mode: initial;
      }

      .content-fix {
        writing-mode: vertical-lr;
      }

      .content-fix > * {
        writing-mode: initial;
      }
    </style>
  </head>
  <body>
    <h2>Actual Behaviour:</h2>
    <div class="flex">
      <h3>col</h3>
      <div class="content"><img src="https://via.placeholder.com/300"/></div>
    </div>
    <br clear="all"/>
    <br/>
    <h2>Desired Behaviour:</h2>
    <div class="flex flex-fix">
      <h3>col</h3>
      <div class="content content-fix"><img src="https://via.placeholder.com/300"/></div>
    </div>
  </body>
</html>