JSFiddle - React, Tailwind, and code Playground

by extempl

HTML

<div class="parent">
<div class="child child1"><img src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="> <p>I want to set the width of this element equals to its height (which is equals to the height of the content of it's  sibling, set by `align-items : stretch`)</p> </div>
   <div class="child child2">
          some text <br>
          some text <br>
          some text <br>
          some text <br>
   </div>
</div>

CSS

.parent {
    display: flex;
    align-items: stretch;
    height: 300px;
    position: relative;
}

.child {
    border: 1px solid black;
    flex: auto;
}

.child1 {
  /* flex-basis: 100%; */
  flex-basis: 0;
  width: 100vh;
  height: 100vh;
}

img {
  
}