css - 我想要从下到上垂直对齐的文本。如何实现它。附上预期的

标签 css

<分区>

我想要从下到上垂直对齐的文本。如何实现它。附上预期的结果。

HTML

<div class="class1">
  <div class="class2">Title from bottom to top</div>
</div>

CSS

.class1 {
background: #1ac6d3;
position: relative;
width: 40px;
height:200px;
}

.class2 {
position: absolute;
top: 35%;
left: 50%;
width: 200px;
}

预期输出

enter image description here

最佳答案

您可以使用text-orientation 然后将其旋转180deg

.class1 {
  background: #1ac6d3;
  width: 40px;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center
}

.class2 {
  text-orientation: sideways;
  writing-mode: vertical-lr;
  transform: rotate(180deg);
  font-weight: bold;
}
<div class="class1">
  <div class="class2">Title from bottom to top</div>
</div>

关于css - 我想要从下到上垂直对齐的文本。如何实现它。附上预期的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58760332/

相关文章:

css - 使用 :focus to style outer div?

jquery - CSS/HTML 弹出窗口不会关闭

html - IE 中的下拉列表会干扰 CSS 悬停样式

css - 改进 CSS 中的文本对齐

当在 div 中列出时,css 选项卡式菜单内容不出现

css - 使用 CSS 在不同位置垂直对齐多个堆叠元素

html - 如何在 Bootstrap 4 中添加新的大断点(仅限 CSS)

javascript - CSS 是样式化 HTML 文档的唯一方法吗?

javascript - Bootstrap 下拉效果 - jQuery

javascript - 使用 Javascript 函数更改 CSS 样式