首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将段落显示为内含缩写的列?

如何将段落显示为内含缩写的列?
EN

Stack Overflow用户
提问于 2021-07-08 16:40:06
回答 2查看 31关注 0票数 0

我在zengarden上练习css。

I want something like this, but with no h3 column.

HTML

代码语言:javascript
复制
<div class="preamble" id="zen-preamble" role="article">
        <h3>The Road to Enlightenment</h3>
        <p>Littering a dark and dreary road lay the past relics of browser-specific tags, incompatible 
            <abbr title="Document Object Model">DOM</abbr>s, broken <abbr title="Cascading Style Sheets">CSS</abbr> 
        support, and abandoned browsers.</p>
        <p>We must clear the mind of the past. Web enlightenment has been achieved thanks to the tireless efforts of folk like the 
            <abbr title="World Wide Web Consortium">W3C</abbr>, 
            <abbr title="Web Standards Project">WaSP</abbr>
        , and the major browser creators.</p>
        <p>The CSS Zen Garden invites you to relax and meditate on the important lessons of the masters. Begin to see with clarity. Learn to use the time-honored techniques in new and invigorating fashion. Become one with the web.</p>
</div>

我也试过了。

代码语言:javascript
复制
.preamble :not(h3){
    display: flex;
}

I got this.

也许是因为p标签中的abbr。有没有办法实现我想要的东西?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2021-07-08 17:46:07

看起来CSS columns很适合这里。如果标题应跨越整个宽度,则可以设置column-span属性。

您可能还需要根据自己的喜好设置段落样式(例如调整页边距)。

有关详细信息,请参阅MDN Multiple-column layout

代码语言:javascript
复制
.preamble {
  columns: 3;
}

h3 {
  column-span: all;
}
代码语言:javascript
复制
<div class="preamble" id="zen-preamble" role="article">
  <h3>The Road to Enlightenment</h3>
  <p>Littering a dark and dreary road lay the past relics of browser-specific tags, incompatible
    <abbr title="Document Object Model">DOM</abbr>s, broken <abbr title="Cascading Style Sheets">CSS</abbr> support, and abandoned browsers.</p>
  <p>We must clear the mind of the past. Web enlightenment has been achieved thanks to the tireless efforts of folk like the
    <abbr title="World Wide Web Consortium">W3C</abbr>,
    <abbr title="Web Standards Project">WaSP</abbr> , and the major browser creators.</p>
  <p>The CSS Zen Garden invites you to relax and meditate on the important lessons of the masters. Begin to see with clarity. Learn to use the time-honored techniques in new and invigorating fashion. Become one with the web.</p>
</div>

票数 0
EN

Stack Overflow用户

发布于 2021-07-08 17:14:33

您需要从该div中删除h3以使其居中

代码语言:javascript
复制
.preamble {
  display: flex;
}

h3{
  text-align: center;
}
代码语言:javascript
复制
<h3>The Road to Enlightenment</h3>
<div class="preamble" id="zen-preamble" role="article">
  <p>Littering a dark and dreary road lay the past relics of browser-specific tags, incompatible
    <abbr title="Document Object Model">DOM</abbr>s, broken <abbr title="Cascading Style Sheets">CSS</abbr> support, and abandoned browsers.</p>
  <p>We must clear the mind of the past. Web enlightenment has been achieved thanks to the tireless efforts of folk like the
    <abbr title="World Wide Web Consortium">W3C</abbr>,
    <abbr title="Web Standards Project">WaSP</abbr> , and the major browser creators.</p>
  <p>The CSS Zen Garden invites you to relax and meditate on the important lessons of the masters. Begin to see with clarity. Learn to use the time-honored techniques in new and invigorating fashion. Become one with the web.</p>
</div>

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68298251

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档