Multi-column la...LOGIN

Multi-column layout - Columns

In order to facilitate the implementation of multi-column layouts similar to newspapers and magazines in Web pages, W3C specially added a multi-column layout module (CSS Multi Column Layout Module) to CSS3. It is mainly used in multi-column layout of text. This layout has been used in newspapers and magazines for decades, but it is still quite difficult to achieve such an effect on a Web page. Fortunately, CSS3 Multi-column layouts can be easily implemented. Next, let’s learn about multi-column layout together.

Syntax:

columns:<column-width> || <column-count>

Example: To display 2 columns, the width of each column is 200px, The code is:

columns: 200px 2;

So far most mainstream browsers support it:

QQ截图20161020165549.png

CSS3 multi-column properties

In this chapter we will learn the following multi-column properties of CSS3:

  • column-count

  • column-gap

  • column-rule-style

  • column-rule-width

  • column-rule-color

  • column-rule

  • column-span

  • column- width


Next Section
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文网(php.cn)</title> <style> .newspaper { -moz-column-count:3; /* Firefox */ -webkit-column-count:3; /* Safari and Chrome */ column-count:3; } </style> </head> <body> <p><b>注意:</b> Internet Explorer 9及更早 IE 版本浏览器不支持 column-count 属性。</p> <div class="newspaper"> “当我年轻的时候,我梦想改变这个世界;当我成熟以后,我发现我不能够改变这个世界,我将目光缩短了些,决定只改变我的国家;当我进入暮年以后,我发现我不能够改变我们的国家,我的最后愿望仅仅是改变一下我的家庭,但是,这也不可能。当我现在躺在床上,行将就木时,我突然意识到:如果一开始我仅仅去改变我自己,然后,我可能改变我的家庭;在家人的帮助和鼓励下,我可能为国家做一些事情;然后,谁知道呢?我甚至可能改变这个世界。” </div> </body> </html>
submitReset Code
ChapterCourseware