Alignment of 2 columns of text - html

I'd like the text of my second column to start at the same level as the first paragraph of the first column (Lorem Ipsum text). Is it possible? Currently it starts at the same level as my H2 text which doesn't look good. Thanks
http://jsfiddle.net/Grek/znD9f/
<div class="article twocolumns">
<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:
.twocolumns {
-webkit-column-count: 2; /* Safari and Chrome */
-moz-column-count: 2; /* Firefox */
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%; */
}
.article h1, .article h2 {
margin-top: -4px;
padding-bottom: 2px;
}

In that case you need to use the .twocolumns class to div that doesn't have your heading i.e. h2 element like this
<div class="article">
<h2>Biography</h2>
<div class="twocolumns">
<p>Lorem ipsum dolor sit amet,....
and reset the default margin and padding for p element to make it more clear.
p
{
margin:0;
padding:0;
}
So basically apply .twocolumns class to those element which you want to break into two columns. In your case you doesn't want to have heading in that. So exclude it from there and put it outside.
JS Fiddle

What about just moving your H2 tag outside of that div?
http://jsfiddle.net/enigmarm/znD9f/4/
Massage the CSS a bit to get it the way you want.
<h2 class="article">Biography</h2>
<div class="article twocolumns">

It is possible, take a look at this changed fiddle: http://jsfiddle.net/znD9f/2/
Tweak the HTML a little by moving the h2 out and wrapping the paragraphs in two columns.
<div class="article">
<h2>Biography</h2>
<div class="twocolumns">
<p> ... <p>
...
</div>
</div>
And tweak the CSS a little to align both columns:
.article p {
margin-top: 3px;
}
I hope that solves your problem. It works on your example at least.

It's not yet supported in Firefox, but the following should work in Chrome, Safari, Opera 11.1+, and IE10:
.article h1, .article h2 {
-webkit-column-span: all;
column-span: all;
}
For more information: https://developer.mozilla.org/en-US/docs/CSS/column-span.
And here's further information: http://webdesign.tutsplus.com/tutorials/htmlcss-tutorials/an-introduction-to-the-css3-multiple-column-layout-module/.
Until this has broader browser support, just move the heading outside the .twocolumns div.

Related

Resize a specific width div in mobile phone

I have a background-image (size: contain) and a div (position: absolute).
The main issue is that when I change the screen size (mobile size), the box is positioned on the left and it doesn't remain fixed in the place where it is supposed to stay. How can I achieve this or is there another way to do it and having the same result using mobile/laptop? My code for the content is as follows:
body{
background-color: #000;
text-align: center;
margin: 0;
}
#fase_0 {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-image: url(https://i.imgur.com/FJxBokN.png);
background-size: contain;
height: 100%;
width: 100%;
background-repeat: no-repeat;
background-position: center top;
}
.disclaimer {
position:absolute;
right:33%; top:9%;
width:420px; height:200px;
overflow: auto;
text-align: left;
font-size: 12px;
color: #8f8f8f;
font-family: "DejaVu Serif";
}
<div id="fase_0">
</div>
<div class="disclaimer">
Lorem ipsum dolor sit amet, consectetur adipiscing 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. 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.
</div>
Here the codepen link: CodePen
I advise you to have your code like this:
:root {
--width: 1vw;
}
body {
background-color: #000;
text-align: center;
margin: 0;
}
#fase_0 {
background-image: url(https://i.imgur.com/FJxBokN.png);
background-size: contain;
height: 100%;
width: 100%;
background-repeat: no-repeat;
background-position: center top;
position: absolute;
}
.disclaimer {
position: relative;
width: 36%;
height: calc(var(--width)*653*1920/94800);
overflow: auto;
text-align: left;
font-size: 12px;
color: #8f8f8f;
font-family: "DejaVu Serif";
margin: 5% auto 0;
padding-left: 4%;
}
#media (orientation: portrait) {
#fase_0 {
background-size: cover;
}
.disclaimer {
width: 70%;
height: 25%;
margin-top: 12.5%;
padding-left: 10%;
}
}
<html lang="en">
<body translate="no">
<div id="fase_0">
<div class="disclaimer">
Lorem ipsum dolor sit amet, consectetur adipiscing 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. 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.
</div>
</div>
</body>
</html>
This would only work if the "#fase_0" is equal to the width of the window; if it's not you'll have a bit more problem but that could still be achievable via JS, but not pure CSS as I did, now.
If you want that you can tell me and I'll edit my message to what you want.
P.S. Do not trust the snippet but use the code manually in an HTML file
EDIT 1: Fixing the snippet.
EDIT 2: Adding the JS code for no full-width containers:
function centreAlign() {
let a = document.getElementById("fase_0").getBoundingClientRect().width / 100;
document.documentElement.style.setProperty("--width", a + "px");
}
centreAlign()
:root {
--width: 1vw;
}
body {
background-color: #000;
text-align: center;
margin: 0;
}
#fase_0 {
background-image: url(https://i.imgur.com/FJxBokN.png);
background-size: contain;
height: 100%;
width: 100%;
background-repeat: no-repeat;
background-position: center top;
position: absolute;
}
.disclaimer {
position: relative;
width: 36%;
height: calc(var(--width)*653*1920/94800);
overflow: auto;
text-align: left;
font-size: 12px;
color: #8f8f8f;
font-family: "DejaVu Serif";
margin: 5% auto 0;
padding-left: 4%;
}
#media (orientation: portrait) {
#fase_0 {
background-size: cover;
}
.disclaimer {
width: 70%;
height: 25%;
margin-top: 12.5%;
padding-left: 10%;
}
}
<html lang="en">
<body translate="no">
<div id="fase_0">
<div class="disclaimer">
Lorem ipsum dolor sit amet, consectetur adipiscing 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. 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.
</div>
</div>
</body>
</html>
With this JS code, you can run the function centreAlign to, well, centre align the disclaimer.

Why is the grid-row-gap different from the grid-column-gap? [duplicate]

This question already has answers here:
What is the default padding and/or margin for a p element (reset css)?
(5 answers)
Closed 3 years ago.
I am learning how to use grid. I have set the grid-column-gap and grid-row-gap both to 10px but, as you can see, the two gaps appear of different sizes. Why is that?
I have tried to add margin:0 to the p as I have read this suggestion from previous threads. When I do so the grid-column-gap and grid-row-gap appear of the same size but the pink color of the main container disappears, why is that? Here the link to codepen https://codepen.io/Alicinetto/pen/NVqqmo
.container {
background: pink;
display: grid;
grid-template-columns: 1fr 1fr;
grid-column-gap: 10px;
grid-row-gap: 10px;
}
main>p {
background: #fff;
padding: 20px;
margin: 0;
}
<main class="container">
<p>
"Lorem ipsum dolor sit amet, consectetur adipiscing 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.</p>
<p>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,</p>
<p>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.</p>
</main>
That is because the <p> element has native top and bottom margins applied by the browser's default stylesheet. If you set margin: 0 on the <p> element then the issue will go away.
main>p {
background: #fff;
padding: 20px;
margin: 0;
}
If you want to retain some separation between the container and it's inner <p> elements, then set a 10px padding on .container:
.container {
background: pink;
display: grid;
grid-template-columns: 1fr 1fr;
grid-column-gap: 10px;
grid-row-gap: 10px;
padding: 10px;
}
main>p {
background: #fff;
padding: 20px;
margin: 0;
}
<main class="container">
<p>
"Lorem ipsum dolor sit amet, consectetur adipiscing 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.</p>
<p>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,</p>
<p>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.</p>
</main>
The paragraphs have margin on the bottom. If you add
p {
margin: 0;
}
the row gaps are the same.

Why does my HTML DIV push content in when invisible, rather than display above and obscure the other content when visible?

I'm trying to, using only HTML and CSS (no Javascript), when the user hovers over an element (a <div>), display another (<div>) element.
My desired result is this: The second element (div#hover-content, in my case) should be displayed above the content which is outside of the two divs, obscuring the content that happens to be placed "below" it, and should remain visible until the user moves the mouse pointer outside the two. (I can put that content into a third div if that makes it easier.) The page content must not reflow when the hiding/showing happens. I don't know at design time what the exact positions of the two will be, but I do know that they will be adjacent.
I have been experimenting with float, clear, visibility and z-index which, if I understand things correctly, should be what I am after, but I can't seem to get the effect I want.
Below is a minimal working example largely demonstrating the behavior I don't want. Currently the content outside the hover box is pushed in from the left by div#hover-content even when that has visibility:hidden.
If anyone can point out the error of my ways and suggest a solution, I would be very grateful.
<html>
<head>
<style>
#hover-target, #hover-content { max-width: 20em; }
#hover-target:hover ~ #hover-content, #hover-content:hover { visibility: visible; opacity: 1; }
#hover-content, #hover-content p { margin: 0; padding: 0; border: 0; }
#hover-content { visibility: hidden; float: left; white-space: no-wrap; background: grey; outline: 1px red solid; z-index: -40; }
#hover-content p { margin-bottom: 1em; color: yellow; }
body p { margin-left: 2em; max-width: 50em; z-index: 1; }
</style>
</head>
<body>
<div id="hover-target">HOVER HERE</div>
<div id="hover-content">
<p>This is hover box content. It should appear on top of Lorem ipsum, obfuscating the latter.</p>
<p>Blah blah blah</p>
<p>Blah blah blah #2</p>
<p>Blah blah blah #3</p>
<p>Blah blah blah #4</p>
<p>It should be width-constrained, but not push Lorem ipsum to the right whether the hover box is visible or not.</p>
<p>The exact positions of the hover target and the hover box are unknown at design time.</p>
</div>
<!-- I can easily introduce another DIV here surrounding the below, if it helps -->
<!-- div ... -->
<p>Lorem ipsum dolor sit amet, consectetur adipiscing 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>At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.</p>
<!-- /div -->
</body>
</html>
You have #hover-content floated, so naturally, this will move around to accomodate other content. You should use absolute positioning instead. E.g.:
#hover-content{position:absolute;}
Then adjust its left, right, top, and bottom properties to span the width and height of the thing it needs to cover.
Addressing OP's question
It would be best to place both #hover-content and #hover-target inside a parent container (say #hover-container). Then apply
#hover-container{position:relative;}
to this container so that it becomes the offset parent of both elements. Then if you apply:
#hover-content{top:0px;bottom:0px;left:0px;right:0px}
...in combination, the #hover-target piece will establish the dimensions (alone) of the container, and the #hover-content piece will follow along using these dimensions for its 4 edges.
Like this ? I changed css visibility to css display
http://codepen.io/anon/pen/GysCm
<html>
<head>
<style>
#hover-target, #hover-content { max-width: 20em; }
#hover-target:hover ~ #hover-content, #hover-content:hover { display: block; opacity: 1; }
#hover-content, #hover-content p { margin: 0; padding: 0; border: 0; }
#hover-content { display: none; float: left; white-space: no-wrap; background: grey; outline: 1px red solid; z-index: -40; }
#hover-content p { margin-bottom: 1em; color: yellow; }
body p { margin-left: 2em; max-width: 50em; z-index: 1; }
</style>
</head>
<body>
<div id="hover-target">HOVER HERE</div>
<div id="hover-content">
<p>This is hover box content. It should appear on top of Lorem ipsum, obfuscating the latter.</p>
<p>Blah blah blah</p>
<p>Blah blah blah #2</p>
<p>Blah blah blah #3</p>
<p>Blah blah blah #4</p>
<p>It should be width-constrained, but not push Lorem ipsum to the right whether the hover box is visible or not.</p>
<p>The exact positions of the hover target and the hover box are unknown at design time.</p>
</div>
<!-- I can easily introduce another DIV here surrounding the below, if it helps -->
<!-- div ... -->
<p>Lorem ipsum dolor sit amet, consectetur adipiscing 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>At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.</p>
<!-- /div -->
</body>
</html>
Making #hover-content positioned absolute will take it out of the flow. You may have to position an outer div relative and then position #hover-content within the outer div to make things work if the page is scrolled.

Split text in 2 columns not working

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%; */
}
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.
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".

Left floating div's with bottom border not the same size

My designer uses this technique in a lot of designs and I can't decide the best way of css'ing this so it's automagically fluid (as it's going into a cms)
Basically, when floating a 2column div structure I would like there to be a bottom border per div. I would put the border on a wrapping element but there needs to be a gap between the two divs (margin-right). The problem is that the two divs are different sizes depending on content. height:100% will not seem to do the trick (even when making the parent 100%). I need the two divs's borders to be level with each other.
Attached is some sample code pre any formatting css- only successful way I have been able to do this is by setting the height per container, which in this case will not work, needs to be fluid.
Thank you !!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>What's the best way?!</title>
<style type="text/css">
div.col50>div{width:45%; float:left; border-bottom:1px solid #000;}
div.col50>div+div{margin:0 0 0 5%;}
div.col50+div.col50{margin:50px 0 0;}
div.col50:before, div.col50:after { content: "\0020"; display: block; height: 0; overflow: hidden; }
div.col50:after { clear: both; }
div.col50{zoom:1;}
</style>
</head>
<body>
<div class="col50">
<div>
<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>
</div>
<div>
<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>
</div>
</div>
</body>
</html>
Try to make 3 <div>'s:
Left <div> with float:left;width:45%;margin-right:5%;
Right <div> with float:right;width:50%;
Bottom <div> with clear:both;width:100%;
Inside bottom <div> you can create two <div>'s with border (floated left and right).