简体   繁体   English

将文本垂直对齐到另一个文本旁边的顶部

[英]Vertically align text to the top beside another text

I am having a div with various texts.我有一个包含各种文本的 div。 I need to make the am and pm on the top.我需要把上午和下午放在顶部。

My HTML code is-我的 HTML 代码是-

<div class="agendaBlackDiv">
  <span class="agendaTimeStop">10:00</span >
  <span>a.m.</span>
  <text>-</text>
  <span class="agendaTimeStop">11:30</span>
  <span>p.m.</span>
</div>

Here is JSfiddle link- Fiddle Link这是 JSfiddle 链接-小提琴链接

== Hi now define your .text class two property as like this == 嗨,现在像这样定义你的.text属性

.text {
    display: inline-block;
    vertical-align: top;
}

Demo演示

Just change your css class from只需将您的 css 类从

text
{
    color:white;
}

to

text
{
    color:white;
    vertical-align: top;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM