html - 如何设置 dt 和 dd 的样式,使它们在同一行?

使用 CSS,我如何设置以下样式:

<dl>
    <dt>Mercury</dt>
    <dd>Mercury (0.4 AU from the Sun) is the closest planet to the Sun and the smallest planet.</dd>
    <dt>Venus</dt>
    <dd>Venus (0.7 AU) is close in size to Earth, (0.815 Earth masses) and like Earth, has a thick silicate mantle around an iron core.</dd>
    <dt>Earth</dt>
    <dd>Earth (1 AU) is the largest and densest of the inner planets, the only one known to have current geological activity.</dd>
</dl>

所以 dt 的内容在一列中显示,而 dd 的内容在另一列中显示,每个 dt 和对应的dd 在同一行? IE。产生的东西看起来像:

最佳答案

dl {
  width: 100%;
  overflow: hidden;
  background: #ff0;
  padding: 0;
  margin: 0
}
dt {
  float: left;
  width: 50%;
  /* adjust the width; make sure the total of both is 100% */
  background: #cc0;
  padding: 0;
  margin: 0
}
dd {
  float: left;
  width: 50%;
  /* adjust the width; make sure the total of both is 100% */
  background: #dd0;
  padding: 0;
  margin: 0
}
<dl>
  <dt>Mercury</dt>
  <dd>Mercury (0.4 AU from the Sun) is the closest planet to the Sun and the smallest planet.</dd>
  <dt>Venus</dt>
  <dd>Venus (0.7 AU) is close in size to Earth, (0.815 Earth masses) and like Earth, has a thick silicate mantle around an iron core.</dd>
  <dt>Earth</dt>
  <dd>Earth (1 AU) is the largest and densest of the inner planets, the only one known to have current geological activity.</dd>
</dl>

https://stackoverflow.com/questions/1713048/

相关文章:

?">javascript - 哪些浏览器支持<script async ="async"/>?

javascript - 禁止从 HTML 页面拖动图像

html - CSS中下一个元素的选择器的语法是什么?

html - 如何在多行 flexbox 布局中指定换行符?

javascript - 可以用 innerHTML 插入脚本吗?

html - 如何防止滚动条重新定位网页?

html - 您应该使用 .htm 还是 .html 文件扩展名?有什么区别,哪个文件是正确的?

javascript - 在网站上打印当前年份的最短方法

javascript - 可以即时进行语法突出显示的文本区域?

javascript - 就 HTML 文件路径位置而言, "./"(点斜杠)指的是什么?