Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

I would like to use CSS to present a two-column layout. The markup I am using is this

<div style="-webkit-column-count: 2;
            -webkit-column-rule: 1px solid black;
            -webkit-column-width: 80px;
             margin-left:20px;margin-top:20px;">
    <div id="picturebox" style="">picture box</div>
    <div id="nme">name</div>
</div>

Is there a way to give one column a width of 20px and one column a width of, say, 80px?

like image 804
Joe Morris Avatar asked Mar 16 '10 10:03

Joe Morris


People also ask

How do I restrict column width in CSS?

1) Specify width for each column in <th> according to your need. 2) Add word wrap for each <td> in <tr> of the <table> .

Is it allowed to use different column widths in HTML?

HTML tables can have different sizes for each column, row or the entire table. Use the style attribute with the width or height properties to specify the size of a table, row or column.


2 Answers

No, there isn't a way.

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

like image 147
Quentin Avatar answered Sep 20 '22 14:09

Quentin


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

like image 26
Oriol Avatar answered Sep 19 '22 14:09

Oriol