473,473 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Three Columns Div question

144 New Member
hello,

I have a header. Right now, it is only a div wrapped in another div, and placed at the center of the screen using the css margin:0 auto.

I want to make it into 3 divs. Left, Center (the header) and Right. The reason is that, there's a line at the header image that should run from the left side to the right side of the screen. Right now, there's only empty space at the left and the right side of the header image.

The question is, how do i place the header (center div) to be centered? The header div has a fixed layout, it's always 900px width. I think the margin:0 auto won't work anymore. How should i set the width of the left and right divs?


Thank you.
Jun 8 '10 #1
7 2077
JKing
1,206 Recognized Expert Top Contributor
Hi,

I am having trouble understanding the layout you are looking to achieve.

Do you have an example or an image that would accurately convey the layout you are looking for?
Jun 17 '10 #2
thesti
144 New Member
Hello JKing, thanks for the reply.

Here is my current layout



and here is what i want to achieve



The difference are in the header, menu and the footer part. Notice the line that continues to the left and the right of the screen from the content (center).

I wonder how to set the width so that the center part will always be centered on the screen no matter what the resolution is.

Thank you.
Jun 20 '10 #3
JKing
1,206 Recognized Expert Top Contributor
My suggestion is to wrap your header and footer in separate container divs. Apply the background to the container div. Then center the header and footer divs as you have done before.
Jun 23 '10 #4
thesti
144 New Member
Great Idea JKing.

never thought of it before. Thank you.

Since the end of the left and the end of the right footer image has different color, I'm thinking of creating 2 absolute-positioned divs with z-index lower than the center, or can a single div has two different background-image? one for the left and one for the right.

Thank you
Jun 24 '10 #5
hellodipak
26 New Member
all you need to do is -
<div id="headerContainer" style="background-image:yourHeaderbgImage;">
<div id="header" style="margin:0 auto; width:900px;">
your header content, that includes navigation too
</div>
</div>

<div id="bodyContainer" style="margin:0 auto; width:900px;">
Your Body Content
</div>

<div id="footerContainer" style="background-image:yourFooterbgImage;">
<div id="header" style="margin:0 auto; width:900px;">
your footer content
</div>
</div>

regard, Dipak.
Jun 24 '10 #6
thesti
144 New Member
Oh, i forget. The background image of the left hand side and the right hand side is different.

Notice that the blue line of the navigation is larger at the left hand side and it becomes smaller near the end of the right hand side.

That's why i couldn't make a single div, center it, and apply a background-image with repeat-x attribute.
Jun 24 '10 #7
JKing
1,206 Recognized Expert Top Contributor
Hello again,

After playing around for a while I have come up with this example for you. It uses some pretty background colors but I think it illustrates the layout you are trying to get. Appears properly in IE8 and FF

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html>
  3.     <head>    
  4.         <style type="text/css">
  5.         *{padding:0;margin:0;}
  6.         #leftHeaderBg {background-color:red;z-index:1;position:absolute;height:100px;width:100%}
  7.         #rightHeaderBg {background-color:blue;float:right;width:50%;z-index:1;position:absolute;height:100px;}
  8.         #leftFooterBg {background-color:red;z-index:1;position:absolute;height:30px;width:100%;bottom:0;}
  9.         #rightFooterBg {background-color:blue;float:right;width:50%;z-index:1;position:absolute;height:30px;bottom:0;}
  10.         #container {width:100%;z-index:100;position:absolute;text-align:center;}
  11.         #content {background-color:green;width:900px;margin:0 auto;}
  12.         #header{height:100px;width:900px;background-color:#666;margin:0 auto;}
  13.         #footerWrap {position:absolute;bottom:0;z-index:5;width:100%;text-align:center;}
  14.         #footer{width:900px;background-color:yellow;height:30px;margin:0 auto;position:relative;}
  15.         </style>
  16.     </head>
  17.     <body style="">
  18.         <div id="leftHeaderBg">
  19.             <div id="rightHeaderBg">
  20.                 </div>
  21.             </div>
  22.         <div>
  23.         <div id="container">
  24.             <div id="header">
  25.                 <h1>Header</h1>
  26.             </div>
  27.  
  28.             <div id="content">
  29.                 <h1>Content</h1>
  30.             </div>
  31.         </div>
  32.         </div>
  33.         <div id="footerWrap">
  34.             <div id="footer">
  35.                 <h1 style="font-size:15px">Footer</h1>
  36.             </div>
  37.         </div>
  38.         <div id="leftFooterBg">
  39.  
  40.             <div id="rightFooterBg">
  41.             </div>
  42.         </div>
  43.     </body>
  44. </html>
Jun 24 '10 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: anon | last post by:
I am trting to simulate the case available in an excel worksheet where the first three columns are frozen and the rest scroll left and right against this. For example: I have a grid which lists...
1
by: Koen Hakvoort | last post by:
Hello, In order to create a message board like this one http://www.prikpagina.nl/read.php?f=18&i=168071&t=168071 I've build a custom treeview with three colums, derived from the asp.net 2.0 ...
2
by: J055 | last post by:
Hi I've been looking into different ways of formatting columns/rows in the GridView control. I realize now, I think, that once the datasource is bound to the control the original column type...
0
by: cfaheybestpitch | last post by:
Hi There, I have designed a DTS package which extracts a query into an excel file. It uses a query that changes dynamically based on user preferences, so I have used the dynamic property...
16
by: Edward | last post by:
This is a three-column DIV page with a menu bar DIV under them. Easy enough with table layouting but with CSS I can't get it to work: http://tanguay.info/web/examples/threeColumnsColor.htm 1....
2
by: Kaushal Shah | last post by:
Why won't the following code do as expected? Like print Top Three on the top row and bottom three in the bottom row in that order. Thanks for any advice. Kaushal <!DOCTYPE html PUBLIC...
2
by: mil111 | last post by:
Hi, Can anybody help me? I have table1 with 5 columns(first name, last name etc) and table2 with one column. I need to put all of columns from table1 into table2. Into table2 I need to have all...
2
by: shapper | last post by:
Hello, I created a 2 column layout with header and footer: http://www.27lamps.com/public/layout.htm Am I doing this the right way? One problem I have is when giving padding to my col's...
36
by: stateemk | last post by:
I have a db with a table that has many columns of info for various entities. In this table, there are three columns called, entity name, second entity name and third entity name. I need to combine...
1
by: kkshansid | last post by:
i want to make a column in mysql table which display sum of three columns.is it possible?how? eg a table with column price1 price2 price3 totalprice after inserting 3 prices total price...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.