我正在努力地居中和裁剪flex: 1内的垂直旋转文本

.wrapper {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
}

.wrapper-el {
  display: flex;
  flex: 1;
  border: 2px solid #ddd;
}

.tab {
  height: auto;
  width: 30px;
  display: flex;
  justify-content: center;
  align-items: center;
  border: 2px solid tomato;
}

.rotate {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  display: inline-block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-height: 60px;
  max-width: fit-content;
  letter-spacing: 2px;
}
<div class="wrapper">
  <div class="wrapper-el">
    <div class="tab">
      <div class="rotate">title</div>
    </div>
  </div>
  <div class="wrapper-el">
    <div class="tab">
      <div class="rotate">title</div> <!-- isn't centered :/ -->
    </div>
  </div>
  <div class="wrapper-el">
    <div class="tab">
      <div class="rotate">ReallyLongWordNeedsToBeEllipsed</div> <!-- how can this text be trimmed? -->
    </div>
  </div>
</div>

这是一个与我的方法类似的示例,但在我的机器上它看起来如下所示:

enter image description here

推荐答案

你几乎是好的,你错过了一些财产.查看 comments :

.wrapper {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

.wrapper-el {
  display: flex;
  flex: 1;
  min-height: 0; /* added */
  border: 2px solid #ddd;
}

.tab {
  width: 30px;
  display: flex;
  justify-content: center;
  align-items: center;
  border: 2px solid tomato;
}

.rotate {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-height: 60px;
  max-height: 100%; /* added */
  letter-spacing: 2px;
}
<div class="wrapper">
  <div class="wrapper-el">
    <div class="tab">
      <div class="rotate">title</div>
    </div>
  </div>
  <div class="wrapper-el">
    <div class="tab">
      <div class="rotate">title</div> <!-- isn't centered :/ -->
    </div>
  </div>
  <div class="wrapper-el">
    <div class="tab">
      <div class="rotate">ReallyLongWordNeedsToBeEllipsed</div> <!-- how can this text be trimmed? -->
    </div>
  </div>
</div>

Html相关问答推荐

css网格区域的布局不展开,也不显示滚动条

CSS自定义特性中的URL是否可以相对于定义的CSS文件?

为什么XPath返回的元素比我预期的要多?

容器内的SVG图像没有响应

如何最大限度地减少Cookie同意代码对性能的影响?

在一行中对齐文本和图标

当我关闭时,导航栏跳到了新的生产线

在Firefox中,使用写入模式:Vertical-LR时,不随内容扩展的css弹性项

滚动平滑在笔记本电脑上不起作用,但在Nextjs网站的手机浏览器中起作用

Style=背景图像URL引用变成&;Quot;

如何在网格中拥有离散的行

使用简单的 HTML 设计公司徽标和文本

带圆角帽的 CSS 部分边框

在 CSS 中的 div 中获取文本以环绕其他文本?

为什么在使用src与srcdoc时 iframe 内容高度呈现不同?

提交前的验证表单未显示任何验证消息?

如果不透明的元素出现在下方,为什么不透明度会使一个元素出现在另一个元素上方?

用 flexbox 和 overflow 覆盖

那里有一个类似于 ?

所有幻灯片上的 Quarto RevealJS 标题