html - 列中的九个 div。这个怎么设计?

标签 html css

我有九个这样的 div:

<div id="content">
    <div class="example">
        <h2>Lorem ipsum</h2>
        <p>Lorem ipsum dolor sit amet, consectetur adipisicing 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.</p>
    </div>
</div>

怎么排列成如图所示?(css)

enter image description here

最佳答案

你可以通过两种方式做到这一点,第一种......

使用display: inline-block;

Demo

.wrap {
    width: 950px;
}

#content {
    display: inline-block; /* Can also use floats, depends on you */
    width: 300px;
}

第二个使用 column-count 属性(这还没有被广泛支持)

Demo (Demo 可能看起来有点奇怪,需要使用 CSS reset)

.wrap {
    column-count: 3; /* This will cut your content in 3 pieces */
    -moz-column-count: 3;
    -webkit-column-count: 3;
}

关于html - 列中的九个 div。这个怎么设计?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16876962/

相关文章:

javascript - 文字填充效果——模拟一 block 颜色穿过文字

html - HTML 和 CSS 的基本 URL

css - SASS CSS : string interpolation ouputs unexpected value

html - 用于更改刚刚单击的标签外观的 CSS 代码

html - 在 div 悬停时显示 <p>

javascript - 删除下拉列表中的垂直滚动条

Javascript 警报显示在背景图像之前

html - 在 DIV 标签内对齐文本/内容中心

html - 为什么类里面没有顺序?

html - 利用浏览器缓存