【问题标题】:Center align content to the right according to parent header根据父标题居中对齐内容到右侧
【发布时间】:2017-01-23 20:43:27
【问题描述】:

我正在使用 flexbox 构建表格,但遇到了对齐问题。我希望能够将我的内容向右对齐,但我的标题居中。

例子

____________
|   Test   |
|----------|
|     $1   |
|----------|
|   $312   |
|----------|

这是我在JSfiddle 上的一个示例结构,知道如何使用 flexbox 来实现吗?

【问题讨论】:

    标签: html css flexbox


    【解决方案1】:

    https://jsfiddle.net/04Lzxqun/2/ 消除 显示:弯曲; 证明内容:弹性结束; 从 .父div

    .table{
      display: flex;
      flex-direction: row;
    }
    .parent{
      flex-direction: column;
      border: 1px solid black;
      flex-basis: 1 0 50px;
      width: 100%;
    }
    
    .parent div {
      border: 1px solid black;
    }
    .parent span{
      text-align: left !important;
    }
    .parent .header{
      text-align: center !important;
    }
    
    .header {
      background-color: blue;
    }
    
    .empty{
      visibility: hidden;
    }
    

    【讨论】:

    • 谢谢,但不是我问的
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-02-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-02
    • 2019-04-24
    相关资源
    最近更新 更多