Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A clean CSS3 3-column layout, where to start?

Tags:

html

css

I'm currently updating a pretty old website (last update was around 2001), and have agreed to use HTML5 and CSS3.

For the general design, I'm working on a very clean white and gray tones style, with many paddings and margins. My problem resides in the home page: I'd like to have a 3-column centered layout. But where to start? I've tried some floating, but in vain.

Am I doing this right ?

HTML:

<div class="colwrapper">
    <div class="ltcol"></div>
    <div class="ctcol"></div>
    <div class="rtcol"></div>
</div>

CSS:

.colwrapper { width:1020px; }
.ltcol, .ctcol, .rtcol { width:300px; margin:0 10px; padding:10px; }
.ltcol { float:left; }
.ctcol { margin-left:340px; }
.rtcol { float:right; }
like image 240
Jean-Marie Comets Avatar asked Jul 12 '12 11:07

Jean-Marie Comets


People also ask

How do you make a 3 column grid in CSS?

By using grid-template-columns: repeat(3, 1fr) on grid container you will get layout with 3 columns of equal width, and grid layout will by default make all items in each row equal height. Save this answer.

How do you make a table with 3 columns in HTML?

You can create a table using the <table> element. Inside the <table> element, you can use the <tr> elements to create rows, and to create columns inside a row you can use the <td> elements. You can also define a cell as a header for a group of table cells using the <th> element.


1 Answers

your css should be like this:

.ltcol, .ctcol { float:left; }
.rtcol { float:right; }

The purpose of the CSS float property is, generally speaking, to push a block-level element to the left or right, taking it out of the flow in relation to other block elements. This allows naturally-flowing content to wrap around the floated element. This concept is similar to what you see every day in print literature, where photos and other graphic elements are aligned to one side while other content (usually text) flows naturally around the left- or right-aligned element.

For More details you must have to read this intresting article.

See This Demo: http://jsfiddle.net/akhurshid/YRWLV/

like image 51
Ahsan Khurshid Avatar answered Oct 04 '22 02:10

Ahsan Khurshid