html - 将第二个跨度的文本对齐到第一个居中文本的跨度下方

标签 html css alignment text-alignment

我想实现如下效果:

           Some centered quote on screen
                                ~ author

当引用较长时,作者部分应始终在其下方对齐

           Some longered, maybe even
      multi-line centered quote on screen
                                 ~ author

我目前有这个设置,但我想不出处理这个问题的最佳方法是 CSS。

.align-center-page {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.quote-container {
  width: 80%;
  text-align: center;
}
.quote-big {
  font-size: 52px;
  font-weight: bold;
  margin-bottom: 0px;
}
.quote-big span {
  margin: 0px;
  clear: both;
}
.quote-author {
  display: block;
  font-size: 14px;
  font-weight: normal;
  font-style: italic;
  margin-top: 0px;
  text-align: right;
}
.quote-author:before {
  content: "~ ";
}
<div class="align-center-page quote-container">
  <span class="quote-big">@Model.Quote</span>
  <span class="quote-author">@Model.Author</span>
</div>

最佳答案

您必须将 text-align:right 放在 .quote-container

.quote-container {
    width: 80%;
    text-align: right;
}

查看此 working例子

关于html - 将第二个跨度的文本对齐到第一个居中文本的跨度下方,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39518591/

相关文章:

html - 禁用元素的 CSS 选择器

javascript - 我想在 jquery 中加载页面时隐藏所有字段

JavaFX 如何并排居中多个组件

c++ - std::数组对齐

html - 在屏幕上拉伸(stretch) 1 个 div 中包含的图像

javascript - jquery 发布表单不起作用

jquery - div的水平和垂直对齐方式

css - 具有多个视频源的 SVG 蒙版?

html - 在关闭 div 后结束表单,不好的做法?

php - 更改具有相同 ID joomla 的模块标题之一的 ID