How to align dt and dd side-by-side using flexbox with multiple dd underneath the other?

后端 未结 3 1814
一向
一向 2020-12-03 14:24

I am trying to create a list consisting of key-value-pairs where the key is on the left and the values are on the right side one underneath the other.

Author         


        
3条回答
  •  有刺的猬
    2020-12-03 14:57

    How about setting flex-wrap on the dl and have a width > 50% for dd along with margin-left: auto?

    See demo below:

    dl {
      display: flex;
      flex-wrap: wrap;
    }
    dt {
      width: 33%;
    }
    dd {
      margin-left: auto;
      width: 66%;
    }
    Authors
    John Doe
    Jane Doe
    Max Mustermann
    Publishers
    John Doe
    Jane Doe
    Max Mustermann

提交回复
热议问题