html - 具有不同宽度的原始 html 页面中的 block

标签 html css

我有this fiddle它具有三个等宽的 block 。我们怎样才能使它具有不同的大小,比如给定 100%,第一个 block 20%,第二个 block 50%,第三个 block 30%。

<div class="Row">
    <div class="Column">C1</div>
    <div class="Column">C2</div>
    <div class="Column">C3</div>
</div><div class="Row">
    <div class="Column">C1</div>
    <div class="Column">C2</div>
    <div class="Column">C3</div>
</div>


.Row
{
    display: table;
    width: 100%;
    table-layout: fixed;
    border-spacing: 10px;
}
.Column
{
    display: table-cell;
    background-color: red;
}

最佳答案

你可以使用nth-child:

.Row {
  display: table;
  width: 100%;
  table-layout: fixed;
  border-spacing: 10px;
}

.Column {
  display: table-cell;
  background-color: red;
}

.Column:nth-child(1) {
  width:20%;
}
.Column:nth-child(2) {
  width:50%;
}
.Column:nth-child(3) {
  width:30%;
}
<div class="Row">
  <div class="Column">C1</div>
  <div class="Column">C2</div>
  <div class="Column">C3</div>
</div>

关于html - 具有不同宽度的原始 html 页面中的 block ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41962468/

相关文章:

javascript - 使用 slider 调整 div 的不透明度

javascript - 缩小 Canvas 正在被切断

html - IE7 中的 Div 宽度不正确 - 无法设置宽度,如果添加字符,则必须是可扩展按钮

javascript - html/js : is there a "page loaded" event in single page applications?

不同div的CSS不同背景

css - 页脚无法在移动浏览器上正确显示

html - 将整页 html 内容居中

javascript - 如何通过名称获取动画

html - 尝试将 2 组 2 个 div 每组居中放置在包装器的中间

html - 为什么响应式菜单无法正常工作?