【问题标题】:How to style dt and dd so they are on the same line?如何设置 dt 和 dd 的样式,使它们在同一行?
【发布时间】:2010-12-15 08:15:53
【问题描述】:

使用 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。产生的东西看起来像:

【问题讨论】:

标签: html css


【解决方案1】:

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>

【讨论】:

  • 谢谢!这个 CSS 技巧帮助我格式化 Zend 表单,而无需编写表单装饰器类。
  • 您似乎无法使用此方法在“行”之外添加底部边距或填充拖曳空间。
  • 我建议在 dt 样式中添加 clear: left 以确保它们即使需要换行也能保持内联。
  • * { ... } 语句使所有内容都丢失了边距和填充,删除它会扭曲 DL。使用类也不会成功。似乎如果我想要除了 DL 之外的任何东西,我将不得不到处都没有边距和填充......或者?
  • 当您选择(双击)
    中的第一个单词时,这会显得很笨拙。它还会选择
    内的文本,除非在
    和
    之间有空格(或   如果您使用的是 htmlmin)。
【解决方案2】:

根据您如何设置 dt 和 dd 元素的样式,您可能会遇到一个问题:使它们具有相同的高度。例如,如果您想在这些元素的底部添加一些可见边框,您很可能希望在相同的高度显示边框,就像在表格中一样。

对此的一种解决方案是作弊并使每一行都成为“dl”元素。 (这相当于在表中使用 tr) 我们失去了对定义列表的最初兴趣,但另一方面,这是一种获得快速且漂亮样式的伪表的简单方法。

CSS:

dl {
 margin:0;
 padding:0;
 clear:both;
 overflow:hidden;
}
dt {
 margin:0;
 padding:0;
 float:left;
 width:28%;
 list-style-type:bullet;
}
dd {
 margin:0;
 padding:0;
 float:right;
 width:72%;
}

.huitCinqPts dl dt, .huitCinqPts dl dd {font-size:11.3px;}
.bord_inf_gc dl {padding-top:0.23em;padding-bottom:0.5em;border-bottom:1px solid #aaa;}

HTML:

<div class="huitCinqPts bord_inf_gc">
  <dl><dt>Term1</dt><dd>Definition1</dd></dl>
  <dl><dt>Term2</dt><dd>Definition2</dd></dl>
</div>

【讨论】:

  • 你不写quatreVingtCinqPts? :)
【解决方案3】:

我找到了一个对我来说似乎很完美的解决方案,但它需要额外的&lt;div&gt; 标签。 事实证明,不需要像在表格中那样使用&lt;table&gt;标签来对齐,使用display:table-row;和display:table-cell;样式就足够了:

<style type="text/css">
dl > div {
  display: table-row;
}
dl > div > dt {
  display: table-cell;
  background: #ff0;
}
dl > div > dd {
  display: table-cell;
  padding-left: 1em;
  background: #0ff;
}
</style>

<dl>
  <div>
    <dt>Mercury</dt>
    <dd>Mercury (0.4 AU from the Sun) is the closest planet to the Sun and the smallest planet.</dd>
  </div>
  <div>
    <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>
  </div>
  <div>
    <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>
  </div>
</dl>

【讨论】:

  • 为什么它不兼容 XHTML?
  • @DerickSchoonbee - 因为dls 只允许拥有dts 和dds 作为孩子。 dts 只能将内联元素作为子元素。 dds,出于某种原因,可以将块级元素作为子元素。
  • -1 无效的 HTML 4、XHTML 1 或 HTML 5。基本上,您只需要 DI 元素 like myself。但是对于任何这样的元素,你根本不需要像 CSS 表格这样深奥的东西......无论如何,那个元素不存在,所以你不应该使用它。
  • @AndreasRejbrand DI 元素也不是有效的 HTML5
  • @AlexMorley-Finch:我知道。这就是为什么我说我想要这样的元素(DI 来自 XHTML 2.0)。顺便说一句,WHATWG HTML 5 编辑器 Ian Hickson 让我意识到 run-in CSS display 值正是我想要的(在我的例子中,我想要简单的名称-值元数据列表)。
【解决方案4】:

假设你知道边距的宽度:

dt { float: left; width: 100px; }
dd { margin-left: 100px; }

【讨论】:

  • 我不会称之为干净,因为你已经硬编码了边距。
  • 干净:具有简单、清晰、令人愉悦的形状。答案很简短。它用三个语句解决了这个问题。不知道保证金不是问题的一部分。
  • Clean 通常用于这些样式的问题中的标记。无论如何,欢迎使用 StackOverflow,我建议您将这些假设放在问题的主体中,以清楚起见。
【解决方案5】:

这里人们建议的大部分内容都有效,但是您应该只将通用代码放入样式表中,并将特定代码放入 html 代码中,如下所示。否则你会得到一个臃肿的样式表。

这是我的做法:

您的样式表代码:

<style>
    dt {
        float:left;
    }
    dd {
        border-left:2px dotted #aaa;
        padding-left: 1em;
        margin: .5em;
    }   
</style>

您的 html 代码:

<dl>
    <dt>1st Entity</dt>
    <dd style="margin-left: 5em;">Consumer</dd>
    <dt>2nd Entity</dt>
    <dd style="margin-left: 5em;">Merchant</dd>
    <dt>3rd Entity</dt>
    <dd style="margin-left: 5em;">Provider, or cToken direct to Merchant</dd>
    <dt>4th Entity</dt>
    <dd style="margin-left: 5em;">cToken to Provider</dd>
</dl>

Looks like this

【讨论】:

  • 我建议不要在可以将其移动到样式表时重复左边距-它们是为了防止代码重复。样式表膨胀可以通过一致的设计来抵消;但即便如此 - 如果防止膨胀是为了节省网络流量,它仍然可以通过将其粘贴在样式表而不是 HTML 中来保存。
  • -1 抱歉。不要使用内联样式,除非你真的别无选择,否则你最终会得到一个非常混乱的 html 标记。
  • 我认为这是一种反模式。
【解决方案6】:

如果您使用 Bootstrap 3(或更早版本)...

<dl class="dl-horizontal">
    <dt>Label:</dt>
    <dd>
      Description of planet
    </dd>
    <dt>Label2:</dt>
    <dd>
      Description of planet
    </dd>
</dl>

【讨论】:

  • 如果您查看 Bootstrap 的 CSS,即使不使用 Bootstrap,您也可以了解如何对其进行样式设置,尽管我确实喜欢该框架。这是一个 sn-p,为了简单起见,忽略了响应式设计的媒体查询:dl{margin-top:0;margin-bottom:20px} dt,dd{line-height:1.428571429} dt{font-weight:700 } dd{margin-left:0} .dl-horizo​​ntal dt{float:left;width:160px;clear:left;text-align:right;overflow:hidden;text-overflow:ellipsis;white-space:nowrap} 。 dl-水平 dd{margin-left:180px}
  • dl-horizontal 实际上是从 Bootstrap 4 中删除的。在 BS4 中,您需要改用网格类。
【解决方案7】:

见jsFiddle demo

我需要一个完全符合项目描述的列表,该列表显示公司的员工,左边是他们的照片,右边是信息。我设法在每个DD 之后使用伪元素来完成清理:

.myList dd:after {
  content: '';
  display: table;
  clear: both;
}

此外,我希望文本只显示在图像的右侧,而不是在浮动图像下方换行(伪列效果)。这可以通过在DD 标记的内容周围添加带有CSS overflow: hidden; 的DIV 元素来实现。您可以省略这个额外的DIV,但DD 标记的内容将包裹在浮动的DT 之下。

玩了一段时间后,我能够支持每个DD 的多个DT 元素,但不能支持每个DT 的多个DD 元素。我尝试添加另一个可选类以仅在最后一个 DD 之后清除,但随后的 DD 元素包裹在 DT 元素下(不是我想要的效果......我希望 DT 和 DD 元素形成列,并且额外的 DD 元素太宽了)。

所有权利,这应该只适用于 IE8+,但由于 IE7 中的一个怪癖,它也适用于那里。

【讨论】:

  • 这里是最好的答案之一。
【解决方案8】:

我有一个不使用浮点数的解决方案!
检查一下 codepen

即

dl.inline dd {
  display: inline;
  margin: 0;
}
dl.inline dd:after{
  display: block;
  content: '';
}
dl.inline dt{
  display: inline-block;
  min-width: 100px;
}



更新 - 2017 年 1 月 3 日rd:我已针对该问题添加了基于 flex-box 的解决方案。检查链接的 codepen 并根据需要对其进行优化。

dl.inline-flex {
  display: flex;
  flex-flow: row;
  flex-wrap: wrap;
  width: 300px;      /* set the container width*/
  overflow: visible;
}
dl.inline-flex dt {
  flex: 0 0 50%;
  text-overflow: ellipsis;
  overflow: hidden;
}
dl.inline-flex dd {
  flex:0 0 50%;
  margin-left: auto;
  text-align: left;
  text-overflow: ellipsis;
  overflow: hidden;
}

【讨论】:

  • 完美!那个邪恶的浮动只是解决了一个问题,同时给了我两个新的问题(比如没有垂直对齐)。很高兴它现在消失了。
  • 这适用于 DD 部分的短文本;如果文本太长,它将环绕并显示在 DT 部分下方。
  • 即使列表中的某些项目为空,此方法也有效。太好了!
  • @tjm1706:我认为,基于 flex 的解决方案可以处理更长的文本大小写。谢谢:)
  • NP: flex-flow: row; 应该是 flex-direction: row; 如果你想要方向和换行分开;否则,使用flex-flow: row wrap; 并删除flex-wrap: wrap;。 @smohadjer,将dt 更改为使用flex: 0 0 auto;,将dd 更改为使用flex: 1 1 0;。
【解决方案9】:

这是另一个选项,它通过显示 dt 和 dd 内联然后在 dd 之后添加换行符来工作。

dt, dd {
 display: inline;
}
dd:after {
 content:"\a";
 white-space: pre;
}

这类似于上面 Navaneeth 的解决方案,但使用这种方法,内容不会像在表格中那样排列,但 dd 会在每一行紧跟 dt,而不管长度如何。

【讨论】:

    【解决方案10】:

    这适用于 IE7+,符合标准,并且允许不同的高度。

    <style>
    dt {
        float: left;
        clear: left;
        width: 100px;        
        padding: 5px 0;
        margin:0;
    }
    dd {
        float: left;
        width: 200px;
        padding: 5px 0;
        margin:0;
    }
    .cf:after {
        content:'';
        display:table;
        clear:both;
    }
    </style>
    
    <dl class="cf">
        <dt>A</dt>
        <dd>Apple</dd>
        <dt>B</dt>
        <dd>Banana<br>Bread<br>Bun</dd>
        <dt>C</dt>
        <dd>Cinnamon</dd>
    </dl>        
    

    See the JSFiddle.

    【讨论】:

      【解决方案11】:

      我需要这样做并使&lt;dt&gt; 内容相对于&lt;dd&gt; 内容垂直居中。我用display: inline-block,和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;
        } 
      }
      

      【讨论】:

        【解决方案12】:

        因为我还没有看到适用于我的用例的示例,所以这是我能够实现的最全面的解决方案。

        dd {
            margin: 0;
        }
        dd::after {
            content: '\A';
            white-space: pre-line;
        }
        dd:last-of-type::after {
            content: '';
        }
        dd, dt {
            display: inline;
        }
        dd, dt, .address {
            vertical-align: middle;
        }
        dt {
            font-weight: bolder;
        }
        dt::after {
            content: ': ';
        }
        .address {
            display: inline-block;
            white-space: pre;
        }
        Surrounding
        
        <dl>
          <dt>Phone Number</dt>
          <dd>+1 (800) 555-1234</dd>
          <dt>Email Address</dt>
          <dd><a href="#">example@example.com</a></dd>
          <dt>Postal Address</dt>
          <dd><div class="address">123 FAKE ST<br />EXAMPLE EX  00000</div></dd>
        </dl>
        
        Text

        奇怪的是,它不适用于display: inline-block。我想如果您需要设置任何dt 元素或dd 元素的大小,您可以将dl 的显示设置为display: flexbox; display: -webkit-flex; display: flex; 和flex 元素的速记dd和 dt 元素就像 flex: 1 1 50% 和 display 一样 display: inline-block。但我还没有测试过,所以请谨慎使用。

        【讨论】:

          【解决方案13】:

          这可以将它们显示为带有边框的表格,它应该响应 3em 第一列的宽度。自动换行只会破坏比列宽的任何单词

           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; } 
          

          &lt;table&gt; 与 &lt;dl&gt; 的比较:

          <!DOCTYPE html>
          <html>
          <style>
          
          dl { display:block;border:2px outset black;margin:1em; line-height:18px;}  
          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; } 
          
          
          .glosstable { border:2px outset #aaaaaa;margin:1em; text-align:left}  
          .glosstable, table, tbody,  tr,  td, dl, dt {font-size:100%; line-height:18px;}
          
          .glossaz { font-size:140%;padding-left:2em;font-weight:bold;color: #00838c; } 
          td.first {width: 2.5em;} 
          </style>
          <body>
          Table<br>
          <table class="glosstable">
            <tr><td class="first">Milk</td>
            <td class="glossdata">Black hot drink</td>
          </tr>
            <tr><td class="first">Coffee2</td>
            <td class="glossdata">Black hot drink</td>
          </tr>
            <tr><td>Warm milk</td>
            <td class="glossdata">White hot drink</td>
          </tr>
          </table>
          DL list <br>
          <dl class="glosstablep">
            <dt>Milk</dt>
            <dd class="glossdata">White cold drink</dd>
            <dt>Coffee2</dt>
            <dd class="glossdata">Black cold drink</dd>
            <dt>Warm Milk</dt>
            <dd class="glossdata">White hot drink</dd>
          </dl>
          
          </body>
          </html>

          【讨论】:

            【解决方案14】:

            我最近需要混合内联和非内联 dt/dd 对,方法是在 &lt;dt&gt; 元素上指定类 dl-inline,后跟内联 &lt;dd&gt; 元素。

            dt.dl-inline {
              display: inline;
            }
            dt.dl-inline:before {
              content:"";
              display:block;
            }
            dt.dl-inline + dd {
              display: inline;
              margin-left: 0.5em;
              clear:right;
            }
            <dl>
                <dt>The first term.</dt>
                <dd>Definition of the first term. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque a placerat odio viverra fusce.</dd>
                <dt class="dl-inline">The second term.</dt>
                <dd>Definition of the second term. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque a placerat odio viverra fusce.</dd>
                <dt class="dl-inline">The third term.</dt>
                <dd>Definition of the third term. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque a placerat odio viverra fusce.</dd>
                <dt>The fourth term</dt>
                <dd>Definition of the fourth term. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque a placerat odio viverra fusce.</dd>
            </dl
            
            >

            【讨论】:

              【解决方案15】:

              CSS 网格布局

              像表格一样,网格布局使作者能够将元素对齐到列和行中。
              https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout

              要更改列大小,请查看grid-template-columns 属性。

              dl {
                display: grid;
                grid-template-columns: max-content auto;
              }
              
              dt {
                grid-column-start: 1;
              }
              
              dd {
                grid-column-start: 2;
              }
              <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>

              【讨论】:

              • 这正是我想要的。 caniuse.com/#feat=css-grid - 没有我想的那么通用,但支持得还算不错。
              • 正是我需要的。其他解决方案有一些要求,例如容器或第一列的固定宽度,但这是完全动态的 :)
              【解决方案16】:

              当样式定义列表为表格时,我通常从以下开始:

              dt,
              dd{
                  /* Override browser defaults */
                  display: inline;
                  margin: 0;
              }
              
              dt  {
                  clear:left;
                  float:left;
                  line-height:1; /* Adjust this value as you see fit */
                  width:33%; /* 1/3 the width of the parent. Adjust this value as you see fit */
              }
              
              dd {
                  clear:right;
                  float: right;
                  line-height:1; /* Adjust this value as you see fit */
                  width:67%; /* 2/3 the width of the parent. Adjust this value as you see fit */
              }
              

              【讨论】:

                【解决方案17】:

                这是一种可能的基于 flex 的解决方案 (SCSS):

                dl {
                  display: flex;
                  flex-wrap: wrap;
                  width: 100%;
                  dt {
                    width: 150px;
                  }
                  dd {
                    margin: 0;
                    flex: 1 0 calc(100% - 150px);
                  }
                }
                

                适用于以下 HTML (pug)

                dl
                  dt item 1
                  dd desc 1
                  dt item 2
                  dd desc 2
                

                【讨论】:

                  【解决方案18】:

                  您可以使用 CSS 网格:

                  dl {
                    display: grid;
                    grid-template-columns: repeat(2, minmax(0, 1fr));
                  }
                  <dl>
                  <dt>Title 1</dt>
                  <dd>Description 1</dd>
                  <dt>Title 2</dt>
                  <dd>Description 2</dd>
                  <dt>Title 3</dt>
                  <dd>Description 3</dd>
                  <dt>Title 4</dt>
                  <dd>Description 4</dd>
                  <dt>Title 5</dt>
                  <dd>Description 5</dd>
                  </dl>

                  【讨论】:

                    【解决方案19】:

                    就我而言,我只想在每个 dd 元素后换行。

                    例如,我想设计这个样式:

                    <dl class="p">
                      <dt>Created</dt> <dd><time>2021-02-03T14:23:43.073Z</time></dd>
                      <dt>Updated</dt> <dd><time>2021-02-03T14:44:15.929Z</time></dd>
                    </p>
                    

                    喜欢这个的默认样式:

                    <p>
                      <span>Created</span> <time>2021-02-03T14:23:43.073Z</time><br>
                      <span>Updated</span> <time>2021-02-03T14:44:15.929Z</time>
                    </p>
                    

                    看起来像这样:

                    创建于 2021-02-03T14:23:43.073Z
                    更新于 2021-02-03T14:44:15.929Z

                    为此,我使用了这个 CSS:

                    dl.p > dt {
                      display: inline;
                    }
                    
                    dl.p > dd {
                      display: inline;
                      margin: 0;
                    }
                    
                    dl.p > dd::after {
                      content: "\A";
                      white-space: pre;
                    }
                    

                    或者你可以使用这个 CSS:

                    dl.p > dt {
                      float: left;
                      margin-inline-end: 0.26em;
                    }
                    
                    dl.p > dd {
                      margin: 0;
                    }
                    

                    我还在每个带有此 CSS 的 dt 元素后添加了一个冒号:

                    dl.p > dt::after {
                      content: ":";
                    }
                    

                    【讨论】:

                      【解决方案20】:

                      我有一个非常相似的问题。我希望在同一行上进行定义,但前提是这些术语没有超出其起始位置。在那种情况下,我希望它在一条新线上。经过多次反复试验,我找到了一个使用浮点数非常简单的解决方案。

                      <html>
                          <style>
                              dl.definitions, dl.definitions dt, dl.definitions dd {
                                  display: block;
                              }
                              dl.definitions dt {
                                  float: left;
                                  clear: right;
                                  margin-inline-end: 2ch;
                              }
                              dl.definitions dd {
                                  float: right;
                                  margin-inline-start: unset;
                                  --definition-indent: 15ch;
                                  width: calc(100% - var(--definition-indent));
                              }
                          </style>
                      
                          <dl class="definitions">
                              <dt> kjsfjk
                              <dt> kjsfjk
                              <dd>
                                  Lorem ipsum dolor sit amet, consectetur adipiscing elit,
                                  sed do eiusmod tempor incididunt ut labore et dolore magna
                                  aliqua. Ut enim ad minim veniam, quis nostrud exercitation
                                  ullamco laboris nisi ut aliquip ex ea commodo consequat.
                                  Duis aute irure dolor in reprehenderit in voluptate velit
                                  esse cillum dolore eu fugiat nulla pariatur. Excepteur
                                  sint occaecat cupidatat non proident, sunt in culpa qui
                                  officia deserunt mollit anim id est laborum.
                              <dt> kjsfjks sdf g fg dgf saf asf asf asdg ag
                              <dd>
                                  Lorem ipsum dolor sit amet, consectetur adipiscing elit,
                                  sed do eiusmod tempor incididunt ut labore et dolore magna
                                  aliqua. Ut enim ad minim veniam, quis nostrud exercitation
                                  ullamco laboris nisi ut aliquip ex ea commodo consequat.
                                  Duis aute irure dolor in reprehenderit in voluptate velit
                                  esse cillum dolore eu fugiat nulla pariatur. Excepteur
                                  sint occaecat cupidatat non proident, sunt in culpa qui
                                  officia deserunt mollit anim id est laborum.
                              <dd> Lorem ipsum dolor sit amet, consectetur adipiscing elit,
                                  sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
                              <dd> Lorem ipsum dolor sit amet, consectetur adipiscing elit,
                                  sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
                              <dt> kjsfjks
                              <dt> kjsfjks
                              <dt> kjsfjks
                              <dd>
                                  Lorem ipsum dolor sit amet, consectetur adipiscing elit,
                                  sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
                              <dd> 
                                  Lorem ipsum dolor sit amet, consectetur adipiscing elit,
                                  sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
                          </dl>
                      </html>
                      

                      【讨论】:

                        【解决方案21】:

                        这是我的解决方案。它就像一个魅力?

                        dl {
                            display: inline-block;
                        
                            &::before {
                                content: " ";
                                display: table;
                            }
                        
                            &::after {
                                clear: both;
                            }
                        
                            dt {
                                margin-right: 5px;
                                display: inline-block;
                                float: left;
                                clear: left;
                            }
                        
                            dd {
                                display: inline-block;
                                float: left;
                                padding-left: 0;
                                margin-left: 0;
                            }
                        }
                        

                        【讨论】:

                          猜你喜欢
                          • 2020-09-06
                          • 1970-01-01
                          • 2012-08-04
                          • 1970-01-01
                          • 1970-01-01
                          • 2014-08-20
                          • 2022-01-20
                          • 1970-01-01
                          • 2015-10-24
                          相关资源
                          最近更新 更多