css - 如何在 CSS 中对齐文本

标签 css text alignment block

我正在聊天,但我遇到了 CSS 方面的问题。

它是这样的:http://i.stack.imgur.com/7v7vV.png

这就是我希望的样子:http://i.stack.imgur.com/7v7vV.png

我该怎么做?

最佳答案

我猜到了标记,但像这样的东西呢 - http://jsfiddle.net/YnPU2/

html:

<p>
    <span class="time">20:20:20</span>
    <span class="author">quwquu</span>
    <span class="text">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</span>
</p>
<p>
    <span class="time">20:20:22</span>
    <span class="author">dfghdg</span>
    <span class="text">when an unknown printer took a galley of type and scrambled it to make a type specimen book.</span>
</p>​

CSS:

p { overflow: hidden; vertical-align: top; }
p span { display: table-cell; }
p .time { width: 62px; }
p .author { width: auto; padding-right: 9px; }
p .text { width: auto; }​

关于css - 如何在 CSS 中对齐文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14159006/

相关文章:

html - 将固定位置父 div 内的 div 设置为 100% 宽度

python - 使用默认等宽字体在终端窗口中对齐 unicode 文本

html - 如何水平居中元素?

CSS text-align 用于文本以外的其他内容(如按钮)

python - Sublime Text键盘映射启动 "extension"

css - 如何在菜单中垂直居中链接?

jquery - 使用 JQuery 更改 CSS 属性

html - 哪个目录可以放置 html src 属性的图像?

html - 如何有条件地将 css 应用于不同的嵌套内容

matlab - Matlab 中的文本和绘图到 LaTeX