Is there a way to specify different widths for columns in CSS3?

落花浮王杯 提交于 2019-11-27 02:14:16

No, there isn't a way.

The feature is designed for content that flows between equal columns.

Oriol

Technically it's not possible to do it with the multi-column property only but for a 2-column layout you can accomplish that by setting a negative margin on one of the sides.

div {
    width: 400px;
    background-color: lightgreen;
}

ul {
    -moz-columns: 2 auto;
    -webkit-columns: 2 auto;
    columns: 2 auto;
    -moz-column-gap: 80px;
    -webkit-column-gap: 80px;
    column-gap: 80px;
    margin-right: -80px;
}
<div>
    <ul>
        <li>Lorem Ipsum Lorem Ipsum</li>
        <li>Lorem Ipsum Lorem Ipsum</li>
        <li>Lorem Ipsum Lorem Ipsum</li>
        <li>Lorem Ipsum Lorem Ipsum</li>
        <li>Lorem Ipsum Lorem Ipsum</li>
        <li>Lorem</li>
        <li>Lorem</li>
        <li>Lorem</li>
        <li>Lorem</li>
    </ul>
</div>

See JSFiddle Demo

You could use the grid property:

.container-grid {
  display: grid;
  grid-template-columns: 20px 50px; /*columns widths*/
  height: 40vh;
}

.col-1 {
  background-color: blue;
}

.col-2 {
  background-color: green;
}
<div class="container-grid">
  <div class="col col-1"></div>
  <div class="col col-2"></div>
</div>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!