html - 如何在 CSS 中创建 3 列布局?

标签 html css

我一直在尝试为我的程序制作一个复杂的 UI,并且我希望能够在我的设计中使用 css 有 3 列。

这是目前我的代码:

<div style="width:100px;">stuff</div>
<div style="width:100px;">stuff</div>
<div style="width:100px;">stuff</div>

但是,由于某种原因,这将显示 3 行不同的内容。

我尝试过改变一些事情,但似乎根本不起作用

我只想在同一个 block 上有 3 列。

最佳答案

如果你想在屏幕上有 3 个不同的区域,有效的方法是:

<style> .third { width: 33.33%; float: left; } </style>

<div class="third"> Something </div>
<div class="third"> Something </div>
<div class="third"> Something </div>

class="third" 正在添加我制作的 {}内部 的 css。 - 这意味着每个 div 都被赋予 width: 33.33% (屏幕的 1/3)和 float: left ,这只会移动区域以便能够移出正常的 CSS 和 HTML 相互堆叠的范围。

希望这有帮助! :)

关于html - 如何在 CSS 中创建 3 列布局?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37495341/

相关文章:

android - 按钮在 Android 上的 '<' 字符后换行

php - Magento - 类别在目录中显示不正确

css - 为什么我的面板在 MD 断点扩展

java - 我的jsp中出现错误

html - 在 Div 中居中水平 UL 导航栏

javascript - 使用类名生成样式属性

javascript - 发布依赖于返回 true 的 javascript 函数的表单

javascript - 创建一个可复制但不克隆的 Angularjs Web 表单

javascript - CSS 框阴影重叠

css - 高度为 : 100% doesn't work 的父 div