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

后端 未结 18 2281
滥情空心
滥情空心 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:54

    I need to do this and have the

    content vertically centered, relative to the
    content. I used display: inline-block, together with vertical-align: middle

    See full example on Codepen here

    .dl-horizontal {
      font-size: 0;
      text-align: center;
    
      dt, dd {
        font-size: 16px;
        display: inline-block;
        vertical-align: middle;
        width: calc(50% - 10px);
      }
    
      dt {
        text-align: right;
        padding-right: 10px;
      }
    
      dd {
        font-size: 18px;
        text-align: left;
        padding-left: 10px;
      } 
    }
    

提交回复
热议问题