开发者

specifying a css div container so that elements exceeding its height continue in its next 'column'

开发者 https://www.devze.com 2023-01-16 17:46 出处:网络
How do I specify a css div container so tha开发者_StackOverflow社区t it enforces column-like behavior, such that when the height of the container is exceeded by the elements in its first \'column\', t

How do I specify a css div container so tha开发者_StackOverflow社区t it enforces column-like behavior, such that when the height of the container is exceeded by the elements in its first 'column', the elements simply continue in the next 'column' of the container. My goal is not to specify columns but just the i) the container height and ii) whatever properties the elements need to have to fill up the 'columns'.

Thanks,

Lille


In the same way that you specify any div, you can give it either a class or an id.

As regards your intent to use the div to enforce 'column-like' behaviour, you're limited to either a limited implementation of CSS columns:

#div_id {
  -moz-column-width: 10em;
  -webkit-column-width: 10em;
  -moz-column-gap: 1em;
  -webkit-column-gap: 1em;
  -moz-column-count: 3;
  -webkit-column-count: 3;
  -moz-column-rule: 1px solid #000;
  -webkit-column-rule: 1px solid #000;
  column-width: 10em; /* not well-implemented yet. */
  column-gap: 1em;
  column-count: 3;
  column-rule: 1px solid #000;
}

If you specify -vendor-column-count: 3 and omit the -vendor-column-width the browser will implement 3 columns with the width automatically calculated by the rendering engine, conversely if you specify the -vendor-column-width: 10em without specifying the -vendor-column-count the browser will calculate the appropriate number of columns to display.

Clearly these CSS3 properties are implemented by only Chrome/Safari (-webkit) and Firefox (-moz).

For cross-browser support you would need to use a JavaScript solution (or use a server-side technology): A List Apart has an article that references a JS implementation.

0

精彩评论

暂无评论...
验证码 换一张
取 消