0

I'd like my text to be split into 2 columns like in a newspaper, but for some reason it is not working. Would you know why? Thanks http://jsfiddle.net/Grek/4cYb2/

<div class="article 2columns">
  <h2>Biography</h2>
  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    <p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?</p>
  <p><strong>LOREM IPSUM</strong></p>
</div>

CSS:

.2columns
{
-moz-column-count:2; /* Firefox */
-webkit-column-count:2; /* Safari and Chrome */
column-count:2;
}
.article {
    float: right;
    width: 400px;
    padding: 60px 82px 49px 82px;
    position: relative;
    z-index: 15;
    margin-top: 90px;
    background: #fff;/* max-width: 23.5%; */
}
Greg
  • 3,025
  • 13
  • 58
  • 106

2 Answers2

4

You can't start a class with a number(Which characters are valid in CSS class names/selectors?) in CSS, change to .columns instead and it will work:

http://jsfiddle.net/Adrift/4cYb2/3/

From the 2.1 Spec:

In CSS, identifiers (including element names, classes, and IDs in selectors) can contain only the characters [a-z0-9] and ISO 10646 characters U+00A1 and higher, plus the hyphen (-) and the underscore (_); they cannot start with a digit, or a hyphen followed by a digit. Identifiers can also contain escaped characters and any ISO 10646 character as a numeric code (see next item). For instance, the identifier "B&W?" may be written as "B\&W\?" or "B\26 W\3F.

Community
  • 1
  • 1
Adrift
  • 58,167
  • 12
  • 92
  • 90
0

The problem is you that your class name 2columns begins with a number. Previously, that wasn't possible, but with HTML5 it is in fact - but it requires a little work.

According to The id attribute got more classy in HTML5, you have to escape your "bad" characters (in this case the number 2) for your selector. The following will work for your class 2columns.

.\32 columns
{
-moz-column-count:2; /* Firefox */
-webkit-column-count:2; /* Safari and Chrome */
column-count:2;
}

Here, 32 is the ASCII representation for the number "2".

kba
  • 19,333
  • 5
  • 62
  • 89