...

View Full Version : Three colum layout in css its so hard ?



char
12-10-2009, 04:55 PM
i am trying to do an three column layout in css i have had some luck but i just cant seem to get it an 100% right as some of the text is over lapping and i cant fit in all the stuff i need


and cant seem to work out the best way two do this layout in just css

here is the html code i have done so fare

<!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>
<link href="sheet2.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>
<body>
<div id="main">
<div id="logo_header">
<img src="images/logo.png" width="250" height="100" />
<div id="banner">
<div class="in_banner_links">
register a hotel find a hotel
</div>
<img src="images/banner.png" width="830" height="319" />
</div>
</div>
<div id="top_menu">
<ul>
<li>menu</li> <li>BED &amp; BREALFASTS</li> <li>INNS &amp; PUBS</li> <li>WEEKENDS EVENTS &amp; TOURS</li><li>PLACES TO VISIT</li>
</ul>
</div>
<div id="right_menu">
<p>least events</p>
<div class="rightmenu_box">
<img src="images/hotel.jpg" width="140" height="99" /></div>
</div>
<div id="left_menu">
<ul>
<li>Home</li>
<li> shop</li>
<li>news</li>
</ul>
</div>
<div id="main_content">
<div class="main_content_box">
<p> Welcome to eu arcu vulputate convallis. Donec enim purus, varius vel egestas in, eleifend malesuada tortor.In volutpat metus sit amet augue pharetra nec mattis libero condimentum. Integer viverra urna ac risus elementum at dictum nisi iaculis.</p>
<p> Suspendisse volutpat urna nec turpis gravida tristique. Suspendisse leo purus, consequat vitae imperdiet vitae, bibendum a nunc. Vestibulum placerat neque nec nibh rutrum aliquam. Nullam ut lorem sed nibh fringilla iaculis et sit rmentum</p>
</div>
</div>
<div id="fotter">
<ul>
<li>ABOUT US</li>
<li>CONTACT US</li>
<li>TERMS & CONDITION</li>
</ul>
</div>
</div>
</body>
</html>


and here is my css


@charset "UTF-8";
/* CSS Document */

body{
background-color:#000;
font:Verdana, Geneva, sans-serif;
color:#F00;
background-image:url(images/background.jpg);
background-repeat:repeat-x;
}

#main{
margin:auto;
width:1000px;
height:auto;
}
#logo_header{
background-image:url(images/logo.png)
height:auto;
width:auto;
}
#banner{
width:830px;
height:333px;
margin-left:auto ;
margin-right:auto;

}

.in_banner_links{
color:#F00;
float:right;
font-size:12px;
font-family:"TrajanPro", Arial, Helvetica, sans-serif;
text-align:center;
}


.in_banner_links:alink{
font-size:16px;
padding:4px;
color:#F00

}
#top_menu{
margin-right:auto;
margin-left:auto;
width:800px;
color:#F00;
font-size:10px;
font-family: Trebuchet, Arial, Helvetica, sans-serif;
text-decoration:none;
}

#top_menu ul{
list-style:none;
color:#F00;
text-decoration:none;
}
#top_menu li {
text-decoration:none;
display:inline;
padding-right:20px;
padding-left:20px;
text-align:center;
}


#top_menu:alink{
color:#F00;
font-size:10px;
font-family:"TrajanPro", Arial, Helvetica, sans-serif;
margin-bottom:40px;
text-decoration:none;
margin-right:20px;
}
a:link{
color:#F00;
text-decoration:none;

}
#right_menu{
float:right;
width:200px;
height:auto;
margin-left:140px;
}
#left_menu{
float:left;
width:190px;
height:auto;
font-size:18px;
}
#left_menu ul{
list-style:none;
color:#F00;
text-decoration:none;
font-size:10px;
}
#left_menu li {
text-decoration:none;
font-size:18px;
}
#main_content{
margin-top:50px;
width:600px;
height:auto;
margin-right:160px;
margin-left:150px;
text-align:center;
font-family:Trajan Pro, Geneva, sans-serif;
font-size:15px;
font
}
.main_content_box{
width:660px;
background-color:#000;
color:#ffffff;
text-align:center;
margin:auto;
font-family:Trajan Pro, Geneva, sans-serif;
font-size:15px;
}

.rightmenu_box{
width:140px;
border:#F00 double;
text-align:center;
}

#fotter{
clear:both;
width:650px;
background:#000;
color:#F00;
margin:auto;
text-align:center;
}

#fotter ul{
list-style:none;
color:#F00;
text-decoration:none;
font-size:10px;
}
#fotter li {
text-decoration:none;
display:inline;
padding-right:20px;
padding-left:20px;
text-align:center;
}


here is an link to my coding live on the web http://tazfan.co.cc/923/

here is an demo of what i am aming for http://tazfan.co.cc/923/demo.jpg

thank you for your help

Excavator
12-10-2009, 05:14 PM
Hello char,
Looks like you have a good start there but your box model (http://www.w3.org/TR/CSS2/box.html)is off.
You have a 200px wide #right_menu but only 160px of right margin on #main_content.

Try replacing your CSS with this (be sure to back your's up!)
@charset "UTF-8";
/* CSS Document */

body{
background-color:#000;
font:Verdana, Geneva, sans-serif;
color:#F00;
background-image:url(images/background.jpg);
/*background-repeat:repeat-y;*/
}

#main{
margin:auto;
width:1000px;
height:auto;
}
#logo_header{
background-image:url(images/logo.png)
height:auto;
width:auto;
}
#banner{
width:830px;
height:333px;
margin-left:auto ;
margin-right:auto;

}

.in_banner_links{
color:#F00;
float:right;
font-size:12px;
font-family:"TrajanPro", Arial, Helvetica, sans-serif;
text-align:center;
}


.in_banner_links:alink{
font-size:16px;
padding:4px;
color:#F00

}
#top_menu{
margin-right:auto;
margin-left:auto;
width:800px;
color:#F00;
font-size:10px;
font-family: Trebuchet, Arial, Helvetica, sans-serif;
text-decoration:none;
}

#top_menu ul{
list-style:none;
color:#F00;
text-decoration:none;
}
#top_menu li {
text-decoration:none;
display:inline;
padding-right:20px;
padding-left:20px;
text-align:center;
}


#top_menu:alink{
color:#F00;
font-size:10px;
font-family:"TrajanPro", Arial, Helvetica, sans-serif;
margin-bottom:40px;
text-decoration:none;
margin-right:20px;
}
a:link{
color:#F00;
text-decoration:none;

}
#right_menu{
float:right;
width:200px;
height:auto;
}
#left_menu{
float:left;
width:190px;
height:auto;
font-size:18px;
}
#left_menu ul{
list-style:none;
color:#F00;
text-decoration:none;
font-size:10px;
}
#left_menu li {
text-decoration:none;
font-size:18px;
}
#main_content{
margin-top:50px;
height:auto;
margin-right:220px;
margin-left:190px;
text-align:center;
font-family:Trajan Pro, Geneva, sans-serif;
font-size:15px;
}
.main_content_box{
background-color:#000;
color:#ffffff;
text-align:center;
margin:auto;
font-family:Trajan Pro, Geneva, sans-serif;
font-size:15px;
}

.rightmenu_box{
width:140px;
border:#F00 double;
text-align:center;
}

#fotter{
clear:both;
width:650px;
background:#000;
color:#F00;
margin:auto;
text-align:center;
}

#fotter ul{
list-style:none;
color:#F00;
text-decoration:none;
font-size:10px;
}
#fotter li {
text-decoration:none;
display:inline;
padding-right:20px;
padding-left:20px;
text-align:center;
}

You might want to have a look at a good 3-column layout example here. (http://bonrouge.com/3c-hf-fluid.php)

char
12-14-2009, 11:45 AM
sorry for the late reply thank you
Excavator

and i am checking out that three colum box module site you sent me now

cheers

thank you very much for your help

LE1
12-15-2009, 11:57 AM
I always try and call divs with the names like "column1 column 2" etc helps keep basics easier.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum