How to style dt and dd so they are on the same line?

后端 未结 18 2295
滥情空心
滥情空心 2020-11-27 10:12

Using CSS, how can I style the following:

Mercury
Mercury (0.4 AU from the Sun) is the closest planet to th
18条回答
  •  无人及你
    2020-11-27 10:40

    this works to display them as table, with border, it should be responsive with 3em the width of the first column. The word-wrap just breaks any words wider than the column

     dl { display:block;
          border:2px solid black;
          margin: 1em;}  
     dt { display:inline-block;
          width:3em;
          word-wrap:break-word;} 
     dd { margin-left:0;
          display:inline;
          vertical-align:top;
          line-height:1.3;} 
     dd:after { content:'';display:block; } 
    

    Comparison of

    with
    :

    
    
    
    
    Table
    Milk Black hot drink
    Coffee2 Black hot drink
    Warm milk White hot drink
    DL list
    Milk
    White cold drink
    Coffee2
    Black cold drink
    Warm Milk
    White hot drink

提交回复
热议问题