You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

为何旋转HTML后div出现垂直滚动?求自适应布局解决方案

问题
  • 对<html>元素应用transform: rotate(-90deg)后,页面出现了非预期的垂直滚动条,不符合需求
  • 浏览器未处于全屏状态时,希望内容能自动在垂直方向收缩以适配文本高度,但给.wrapper设置height: inherit;后仍无法实现该效果
  • 补充:之前@Brett Donald给出的方案仅适用于内容较少的小div,对内容较多的大div无效
现有代码
<html>

<head>
  <style>
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }
    
    html {
      transform: rotate(-90deg);
    }
    
    .wrapper {
      display: flex;
      align-items: center;
      justify-content: center;
      height: 100%;
      width: 100%;
    }
  </style>
</head>

<body>
  <div class="wrapper">
    <div>
      <p>hello how are you</p>
      <p>hello whatever here</p>
      <p>hello testing this</p>
    </div>
  </div>
</body>

</html>

内容的提问来源于stack exchange,提问作者electronixG

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.17 08:35:24