<!DOCTYPE html>
<html class="slr">
<head>
<style>
.slr {
  writing-mode: sideways-lr;
}
</style>
</head>
<body>
  <div dir="rtl" style="inline-size:-moz-fit-content">
    <div style="height:300px">
      <div style="height:100px;width:120px;background:rgba(0,255,0,0.8);float:left;"></div>
    </div>
    <div style="height:200px">
      <div style="height:100px;width:150px;background:rgba(255,0,0,0.8);float:left;"></div>
    </div>
  </div>
  <div style="background:silver">
This text should appear ABOVE the green and red blocks.
  </div>
</body>
</html>