将第二个跨度的文本对齐到第一个居中文本的跨度下方
Align second span's text right under first span that has centered text
我想实现如下效果:
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 示例
在 .quote-container 内放置另一个包装,即显示:内联块;
<div class="align-center-page quote-container">
<div class="display-inline-block">
<span class="quote-big">@Model.Quote</span>
<span class="quote-author">@Model.Author</span>
</div>
</div>
我想实现如下效果:
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 示例
在 .quote-container 内放置另一个包装,即显示:内联块;
<div class="align-center-page quote-container">
<div class="display-inline-block">
<span class="quote-big">@Model.Quote</span>
<span class="quote-author">@Model.Author</span>
</div>
</div>