css - 使用 div 在冒号后水平和垂直排列文本元素

标签 css

鉴于我在 CSS 中有如下所示的元素:

Event Starts: 26 October 2013

Event Ends: 28 October 2013

Location: The Neigh Court Yard, London, E19 4AF

我如何在 CSS 中垂直/水平排列它们,使其看起来像这样:

Event Starts:   26 October 2013

Event Ends:     28 October 2013

Location:       The Neigh Court Yard, London, E19 4AF

到目前为止的代码:

        <div class="fb">
        Event Starts: 26 October 2013<br>
        Event Ends: 28 October 2013<br>
        Location: The Neigh Court Yard, London, E19 4AFF<br>
        Please note that this event has already taken place.
        </div>

最佳答案

给你:

http://fiddle.jshell.net/ghmtzrr5/

<table class="fb">
    <tr>
        <td class="firstCell">
        Event Starts:
        </td>
        <td>
             26 October 2013
        </td>
    </tr>
    <tr>
       <td class="firstCell">
        Event Ends: 
        </td>
        <td>
            28 October 2013
        </td>
    </tr>
    <tr>
        <td class="firstCell">
        Location: 
        </td>
        <td>
            The Neigh Court Yard, London, E19 4AFF
        </td>
    </tr>
    <tr>
        <td colspan="2">
        Please note that this event has already taken place.
        </td>
    </tr>
</table>

table td
{
border: 1px solid black;
}

.firstCell
{
width: 100px;
}

//更新,没有表格

http://fiddle.jshell.net/ghmtzrr5/1/

关于css - 使用 div 在冒号后水平和垂直排列文本元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26596579/

相关文章:

javascript - 传单重叠形状不透明度

html - 如何使边框集中在 css 的菜单下?

php - 如何仅在特定页面中 bundle.min.css(在我的例子中是 contact.php)

css - 为轮播元素设置不同的背景色

javascript - css代码如何将导航放在中间

javascript - 如何在滚动时折叠导航

css - 模态垂直位置中心

javascript - 当您除了过渡状态之外还预定义了 css 状态时,Angular 动画无法正常运行

javascript - 如何在父元素悬停时更改 SVG(作为 react 组件导入)的笔划

jquery - 覆盖滚动条