2

I would like to implement such design using floating CSS divs:

---------------
|Header       |
---------------
|Col1| Row1   |
|    |--------|
|    | Row2   |
---------------
| Footer      |
---------------

I searched around but found no easy way to do it.

How could i achieve this?

Thanks.

EDIT: I want to clarify my problem. I want to have two rows of images next to menu bar on the left. I am trying to use float:left for image layout.

EDIT2: Solved the problem myslef using display:inline-block for image elements instead of float:left.

2
  • Well it is main layout of the page and i don't want to use table for that. Commented Jul 21, 2011 at 15:49
  • 2
    @Joel: Tables aren't suitable for non tabular data. For all we know his left column will form his main page content area and his right column may be repeated quotes etc. Commented Jul 21, 2011 at 15:51

3 Answers 3

4

I would start with a container that has the width of the page. For this example, we'll say width:950px. All of the weird widths are caused because of the borders, so if you removed them, all the the widths would be more regular numbers like 400, 950, 350 etc. Here is the live example: http://jsfiddle.net/edgBP/embedded/result/

<html>
<head>
<style type="text/css">
#maincontent {
    width:950px;
    height:100%;
    margin:0 auto;
}
#header {
    width:946px;
    height:150px;
    border:#000 solid;
    border-width:2px 2px 1px 2px;
}
#leftcolumn {
    width:395px;
    height:703px;
    border:#000 solid;
    border-width:1px 1px 1px 2px;
    float:left;
}
#toprow {
    width:549px;
    height:351px;
    border:#000 solid;
    border-width:1px 2px 1px 1px;
    float:left;
}
#bottomrow {
    width:549px;
    height:350px;
    border:#000 solid;
    border-width:1px 2px 1px 1px;
    float:left;
}
#footer {
    width:946px;
    height:150px;
    border:#000 solid;
    border-width:1px 2px 2px 2px;
    clear:both;
}
</style>
<body>
<div id="maincontent">
    <div id="header">Header Content</div>
    <div id="leftcolumn">Leftcolumn Content</div>
    <div id="toprow">Toprow Content</div>
    <div id="bottomrow">Bottomrow Content</div>
    <div id="footer">Footer Content</div>
</div>
</body>
</html>
Sign up to request clarification or add additional context in comments.

Comments

2

Easiest thing for you would probably be to use a framework:

2 Comments

I've plus oned you but I think its still important for him to understand basic CSS before progressing to the frameworks.
Oh I totally agree, but that's not really something you're going to be able to do through here, ya know? There's plenty of free CSS learning resources out there.
2

Here's a simple example of how to achieve this assuming your main width is 400px wide.

HTML:

<div class='container'>

<div class='leftCol'>
.. your left col content ..
</div>

<div class='rightCol'>
<div>.. row 1 content ..</div>
<div>.. row 2 content ..</div>
</div>

</div>

CSS:

.container {width:400px;float:left;}
.leftCol {width:200px; float:left;}
.rightCol {width:200px; float:right}
.rightCol div {float:left; clear:left;}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.