CSS - 3 Column Layout Design Help
I'm converting a site from a table layout to a css layout. I've got a basic 3 column layout and it seems to work just fine except for one problem.
my left and middle columns will never be set heights and they are different colors. So, is there anyway to make the two divs be the same height so that the colors go all the way down regardless of which column is longer? here are 2 examples, the first is the left column longer(teal) and the second is the middle column longer(white). first example left column longer second example middle column longer thx! Similar TutorialsQuestion title: A 2 column layout, let only the second column scroll horizontally and let them both scroll vertically Hello I did try several idea's, but all failed. Then I did search the web but found a list of > 400.000 in google. If someone is willing to tell me if it is possible and give me some directions, please do. Everything is welcome. I got a list with 3 columns ( basically you could say I have only two columns because 2-3 could be concatenated to together, but they have a different style and justification, but I could live to start with a two column sample) f.e line 1 : value_one - ( some_text - value_two (right justified) ) line 2 : value_one - ( some_text - value_two (right justified) ) line 99:.... e.t.c Column one has a fixed width of 32px. 'some text' can be longer then the wide available and value_two is with 3 spaces appended to column 2. I want that column one is fixed horizontal and that the second and the third column can scroll horizontally. Of course when there are more line's then the height of the container is should be posable to scroll vertically. Finally I need the color behind column one be different then the column 2 and 3. So what I did create is a container with two containers where the left one has a different colour then the right one and above those a container with the list. I have overflow on auto, so I get scroll-bars when necessarily. But my problem is that when I scroll horizontally that my first column scrolls away to the left. Basically my question is. How can I get a 2 column layout, let only the second column scroll horizontally ( first is locked in horizontal place ) and let them scroll both vertically? Hey, So I have a three column layout being implemented as such: html: Code: <div class="content"> <div class="col1 column"></div> <div class="col3 column"></div> <div class="col2 column"> <div class="header">Header</div> </div> </div> CSS: Code: .column { padding: 10px; position:relative; } .header { background:#cfe6f5; color:#416383; font-size:11px; font-family:Arial; font-weight:300; padding-left:15px; } .col1 { float: left; width:250px; } .col2 { margin-left: auto; margin-right: auto; } .col3 { float:right; width:250px; } The problem is that the width of the header div extends all the way to the left and right of the page when it's in the middle column, but behaves the way I want it to (extends to the left and right of the column) when it's in the left or right column. Any ideas? Thanks. --Surgery Hello, I am having difficulty with the center column on the following page: http://cbo4edu.org/index2.html I want to widen the center column so that the CBO NEWS heading touches the blue line which divides the center and right column. When I try to add width to the style sheet the left column moves out of alignment. Any help is much appreciated, thanks! A website generally has a header/footerand then a left column and main column. The left column contains links and the main column contains the content. Years ago I saw a design that was validated and used CSS to achieve a tableless design that actually had the main column content BEFORE the left column links in the sourcecode, but on the site itself, it was like a normal site (left column was on the left and main content was on the right or center). Does this achieve better search engine results by having the main content first in the eyes of the search engines, but in reality, to the people, the left links actually shows up first. Also, can someone provide a link to this or show some coding on what you have seen done to achieve this? I've been wracking my brain without success over the following problem: I want to create a div block (which is included in other div blocks - but that doesn't really matter) that includes a list of links. However, I want to display the list of links in two columns, side by side. So far it's a piece of cake. But here is the tricky part: The links come from a database and therefore I do not know how many there are at any given time. How can I use CSS to seperate the list of links in two columns with each containing exactly half the links? I do want to keep the list of links as one chunk of HTML, without inserting 'class=""' or 'id=""' into the HTML. Any ideas?? Thanks Steve PS: I have one alternative: Count the number of links coming out of the database and enclose the first half in some sort of .leftColumn div and the rest in a .rightColumn div. But as I said, I want to avoid adding divs into the HTML that contains the links... Howdy. Disclaimer: I've been working on a redesign of my homepage, and I decided to go 100% CSS. I'm still learning CSS, so if this has a braindead easy solution, just laugh and point it out to me. The problem: Here is the design I have for my website (forgive the ascii art): Code: +------------------------------------------------------+ | Header | +--------------+---------------------------------------+ | Stuff Bar | Content : :Google | | | : : Ad | | Navigation | : : | | | : : | | Firefox | : : | | Info Box | : +.......| | | : | | Affiliates | : | | | : | +--------------+---------------------------------------+ | Footer | +------------------------------------------------------+ The Content has been artificially "width"ed to be no more than 400px wide. The Google Ad should float all the way to the right on a separate layer to keep out of the way on large monitors. Now, what I want to do is also float every IMAGE from the content all the way to the right on large monitors: Code: +------------------------------------------------------+ | Header | +--------------+---------------------------------------+ | Stuff Bar | Content : :Google | | | : : Ad | | Navigation | : : | | | : : | | Firefox | : : | | Info Box | : +.......| | | : | | Affiliates | : | | | : ------------------------ | | | : +---------------------+ | | | : | IMAGE from Content | | | | : +---------------------+ | | | : ------------------------ | | | : | | | : | +--------------+---------------------------------------+ | Footer | +------------------------------------------------------+ I havn't a clue how to do that correctly. I want the Content to wrap around the image callout. I'd appreciate the pointer. I am working on the new home page which is based on a template. The left sideColumn is working fine, however I am having a few problems with the mainColumn layout. Here is a static image to show what I want it to look like Here are the problems I am having: 1) The #scroll box is place where I want it in IE but in foxfire it is right up against the left side of the #sideColumn partially hidden. There will be text that scrolls into this box and stops. I haven't started on the part yet - in case that makes a difference. Not my choice, but that is what the bosses want. 2) I want the image centered horizontal within the #mainColumn. Here is what I have for the css: #home img { margin: 5px auto 5px auto; } which I thought would do the trick, but it's not. 3) I want the p text to have a 40px margin on the right and left side like the .large does. Here is what I have for the css: #home p, .large { margin: auto 40px auto 40px; } It works for the .large (Welcome to Vitalograph), but not for the text below it. At one point I had it working, but after addtional changes fixing other problems, now it doesn't and I can't figure out why. Here is the xhtml starting at the 2 column part (wrapper): Code: <!--begin wrapper--> <div id="wrapper"> <!--begin side column --> <div id="sideColumn"> <span class="category">Products</span> <ul> <li><a href="/products/spirometers.html">Spirometers</a></li> <li><a href="/products/clinical_trials.html">Clinical Trials</a></li> <li><a href="/products/asthma_copd.html">Asthma & COPD</a></li> <li><a href="/products/smoking_cessation.html">Smoking Cessation</a></li> <li><a href="/products/resuscitaion.html">Resuscitation</a></li> </ul> <span class="category">Resources</span> <ul> <li><a href="/resources/contact_us.html">Customer Support</a></li> <li><a href="/resources/training_services.html">Training & Services</a></li> <li><a href="/resources/exhibitions.html">Exhibitions</a></li> <li><a href="/resources/newsletters.html">Newsletters</a></li> <li><a href="/resources/downloads.html">Downloads</a></li> <li><a href="/resources/useful_links.html">Useful Links</a></li> <li><a href="/resources/industry_information.html">Industry Information</a></li> <li><a href="/resources/industry_information.html">Sitemap</a></li> </ul> </div> <!--end of side column --> <!--begin main column --> <div id="mainColumn"> <!-- InstanceBeginEditable name="Main_Section" --> <div id="home"> <div id="scroll"><span>scrolling news will go hear and stop</span></div> <img src="/images/boys_bubbles.gif" width="485" height="333" alt="boys and bubbles" /> <span class="large">Welcome to Vitalograph</span> <p>Vitalgraph offers a wide range of spirometers along with other asthma management equipment with over 40 years experience. From simple hand-held units to sophisticated Windows based spirometry systems, we have it all. Check out our full line of respiratory equipment under the product category.</p> <p><a href="/about_us/about_us.html">more about us...</a></p> </div> <!-- InstanceEndEditable --> </div> <!--end of main column --> </div> <!--end of wrapper--> Here is the vitalograph_master.css: Code: body { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12px; text-align: center; background-color: #ffffff; color: #515151; margin:0px; padding:10px; } /*page container settings*/ #page { width: 750px; height: 600px; border: 1px solid #5094F9; background-color: #FFFFFF; overflow: hidden; margin: auto; padding: 10px 10px 10px 10px; text-align: left; } /*logo header and tag settings*/ #header { margin: 0; padding-bottom: 5px; width: 450px; height: 36px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: #5094F9; text-align: left; } #header img { vertical-align: -7px; } .tagline { color: #5094F9; font-size: 16; font-style: italic; font-weight: bold; display: inline; clear: both; line-height: 20px; margin-left: 10px; } /*top bar settings*/ #topbar { float: top; height: 20px; background-color: #5094f9; clear: both; padding-left: 10px; text-align: left; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: #FFFFFF; font-size: 12px; font-weight: bold; } #topbar a:link, #topbar a:visited { background-color: inherit; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; text-decoration: none; color: #FFFFFF; font-size: 12px; font-weight: bold; } #topbar a:hover, #topbar a:active { background-color: #FFFFFF; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; text-decoration: none; color: #5094F9; font-size: 12px; font-weight: bold; } #topbar ul { list-style: none; margin: 0; padding-top: 2px; } #topbar li { display: inline; margin-right: 160px; } /*Main Section two columns under top section*/ #wrapper{ padding: 10px 10px 10px 0px; width: 100%; height: 100%; } #sideColumn { float:left; width:155px; height: 78%; background-color: #5094F9; padding-top: 50px; padding-left:10px; padding-bottom:10px; pading-right: 10px; margin-right: 10px; text-align: left; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: #FFFFFF; font-weight: bold; line-height: 20px; } .category { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: #FFFFFF; font-size: 16px; font-weight: bold; letter-spacing: 5px; } #sideColumn a:link, #sideColumn a:visited { background-color: inherit; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; text-decoration: none; color: #FFFFFF; font-size: 12px; font-weight: bold; } #sideColumn a:hover, #sideColumn a:active { background-color: #FFFFFF; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; text-decoration: none; color: #5094F9; font-size: 12px; font-weight: bold; } #sideColumn ul { list-style: none; padding: 15px 0px 15px 10px; margin: 0px; } #mainColumn { padding: 0px; } /*footer*/ .footer { font-family: "Times New Roman", Times, serif; font-size: 9px; color: #999999; } /*text*/ .large { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: #5094F9; font-size: 18px; font-weight: bold; margin-bottom: 15px; } Here is the home.css: Code: /*home page*/ #home { margin: auto; } #home img { margin: 5px auto 5px auto; } #home p, .large { margin: auto 40px auto 40px; } #home a:link, #home a:visited { background-color: inherit; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; text-decoration: none; color: #5094F9; font-size: 12px; font-weight: bold; } #home a:hover, #home a:active { background-color: inherit; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; text-decoration: none; color: #990099; font-size: 12px; font-weight: bold; } #scroll { width: 560px; padding: 5px; background-color: inherit; border: 1px solid #5094F9; margin-bottom: 5px; } Any help or suggestions are greatly appreciated. I am a HTML&CSS novice - I am trying to write a page using a three column layout but the column colour doesn't reach the footer. I understand that this is a common problem and I've looked at a lot of examples on the web of how to work around this or create a better layout but I'm still not sure enough to know which would be the easiest and best to go within the page I have written. I want to avoid images but other than that any help would be great! I have validated the HTML & CSS and they are copied below (could any advice be really specific, as I said this is very new to me!). Thanks HTML: <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Drivers Jonas Information Unit</title> <meta name="keywords" content="1" /> <link rel="stylesheet" type="text/css" href="djiucss.css" media="screen" /> <link rel="stylesheet" type="text/css" href="djiuprintcss.css" media="print" /> </head> <body> <div id="top"> <div id="picture"> <img src="GIF.gif" alt="DJ" width="200" height="100" /> </div> <div id="heading"> <div id="title"><h1>Drivers Jonas Information Unit</h1></div> </div> </div> <div id="left"> <br/><p><a href="about.html">About us</a></p><br/> <p><a href="company.html">Company Information</a></p><br/> <p><a href="legal.html">Legal information</a></p><br/> <p><a href="landreg.html">Land Registry</a></p><br/> <p><a href="research.html">Research</a></p><br/> </div> <div id="right"> <div id="title"><h2> News </h2></div> <ul> <li>The Information Unit has recently acquired a set of new APC guides</li> <li>If you would like any training on databases</li> <li>The Information Unit has created an economy timeline </li> </ul> </div> <div id="main"> <div id="title"><h2>Main stuff</h2></div> <p>Suspendisse adipiscing malesuada lectus. Cras vitae dolor. Donec consequat, lectus sed euismod consequat, ipsum mi mollis nunc, eget nonummy neque purus a tortor. Ut vel lorem. Curabitur mollis mauris id diam. Nam posuere. In placerat sapien ut nisl. Donec volutpat augue ut velit. Proin nec mi sit amet metus placerat egestas. Quisque porttitor massa eu lacus. Donec tristique, neque in sollicitudin euismod, enim tellus varius mauris, id vestibulum est massa id massa. Integer et purus. Vivamus condimentum tincidunt ipsum. Duis augue lorem, pretium vel, cursus at, vulputate sed, neque. Quisque justo. Nunc rhoncus. In ornare venenatis velit. </p> <p>Donec facilisis ante sit amet mauris. Nunc fermentum orci eu quam. Donec vestibulum. Vestibulum ultricies nisl eu eros. Curabitur urna. Duis enim erat, lobortis nonummy, mollis non, porttitor nec, nisi. Phasellus pulvinar purus eu pede. In mollis. Duis sit amet dui et arcu rhoncus auctor. Integer est dui, pharetra vel, volutpat ac, luctus in, elit. </p> <p>Suspendisse adipiscing malesuada lectus. Cras vitae dolor. Donec consequat, lectus sed euismod consequat, ipsum mi mollis nunc, eget nonummy neque purus a tortor. Ut vel lorem. Curabitur mollis mauris id diam. Nam posuere. In placerat sapien ut nisl. Donec volutpat augue ut velit. Proin ne</p> </div> <div id="bottom"> Drivers Jonas Information Unit </div> </body> </html> CSS: #top /*DJ logo and page title - includes h1*/ { color: black; font-family: arial, sans-serif; font-size: 20px; background: #d31145; padding-bottom: 15px; } body { color: black; font-family: arial, sans-serif; font-size:14px } img /*DJ logo*/ { padding: 20px; float:left; } #heading { text-align: center; padding:20px; } /*main page title*/ /*should change all reds to DJ red: #d31145*/ #left, #right, #main { color: white; background: black; } #left { float: left; width:140px; border-right:2px solid #d31145; text-align:left; padding-left: 1em; } #right { float:right; width:140px; border-left:2px solid #d31145; text-align:left; padding-right: 1em; } #main { margin-left: 150px; margin-right: 150px; border-left: 1px solid; border-right: 1px solid; padding: 1em; } #bottom { clear:both; margin: 0; color:black; background: #d31145; font-size: 16px; font-family: Arial, sans-serif; text-align: center; } #title { text-align:center; } a:link {color:white} a:visited {color:silver} a:hover {color:#d31145} a:active {color:#d31145} Hello! I'm new to CSS, so any help would be greatly appreciated! I'm working on this page: sugarhooker[dot]com/testing/index2.html *The CSS is included in the head The right column is suppose to start where it says 'Are you hooked...' It should be right underneath the navigation bar. Anyone know what I'm doing wrong? Thanks in advance! Hi, http://www.dudley.nhs.uk/search.asp has a two column effect. The CSS for it is he http://www.dudley.nhs.uk/css/screen.css I was wondering why if there is a table in the right hand column with a width percentage over 77% there is some horizontal scrolling? This happens in IE. Any help would be greatly appreciated. Thanks. Janusz Jasinski Good morning all, iv been fiddling with css for a couple months now, and iv done a couple pages and i want to do a more advanced style layout Im running into some float problems, im hoping somone can think of a better way to do this. heres a picture of what im roughly immaginging my page layout to look like. The problem i run into is having the 3 nav boxes on the right they seem to mess up any floats in the main window where content would go. heres a picture of how the problem looks: Its like i want to clear the floats inside the main content div, but not clear the div floats outside. Im a bit stumped can anyone help me out, would be happy to explain more or provide css source. any suggestions on a better way to do this. hi guys I've begun trying so I finally can leave <tables> I've started trying with a little opensource template, and now want to be how much correct I am... The following image shows the original design, also with the layers division I've created I'd like to know if I'm going ok with this initial design, or which would you modify, and so on. Then I'll follow up the thread with the code, so I can see if I learned correctly Thanks a lot in advance, I've seen a lot of guides that demonstrate how to make a pure CSS two column layout so that if you have two different background colors, the columns will be the same height no matter which column is taller. However, I'm trying to create a border around the columns and found that these tricks don't work for that. The border only shows up around the content itself. How can I make it so that the border around both columns is as tall as the tallest column? I already have a site up and in progress here, but on the utilities page there I want project descriptions on the right and screenshots/links in the left. I want the code in logical order an not use absolute positioning since that will ruin the automatic vertical pagestretch and require fetching exact coordinates. Ultimately there will be self-managed divs. The text needs to be aligned left to the buttons and the left content centered in its 'area' If this doesn't make sense I can try to explain it better or answer questions here. Oh hey, no URLs allowed for me. Ha. Okay... members.allegro.cc/felix-the-ghost/Utilities.html ^site^ Hello, I'm not new to the web, but a newbie in terms of CSS. Could someone check out the following page and css and let me know why the text is not being wrapped in the overall layout. In other words, why is it running over top of the page footer and not contained. http://www.brainfuelmedia.com/postscript/temp.html and the css is http://www.brainfuelmedia.com/postscript/ps_main.css Thanks for all help. This is driving me nuts. Hi, I'm trying to write a reasonably complex (I think) layout using CSS but I can't get it working. here is a mockup of what it should look like: http://andrew.estyles.com.au/site/sitelayout.gif I basically want the main content area to stretch to fit the content being displayed, and have the right column (in blue) to stretch the whole height of the page. The other three areas are a fixed width/height, although the bottom bar's position must change depending on how long the blue bar is (ie the bottom bar should always be inline with the bottom of the blue bar). Here's my attempt so far: http://andrew.estyles.com.au/site/test.html I can't get the bottom (red) bar to line up with the bottom of the blue bar. If I change the height of the content area, the blue bar does not move but the red bar does. This is the main problem. And also, the website does not display correctly in IE If someone could help me out with these issues I'd be grateful, thanks Is it possible to transform the following structu Code: <div 1> <div 2><div 3><div 4> </div 1> to this visual effect: Code: | div 2 (20 px) | div 3 (auto-adjust width) | div 4 (20px) | Now there would probably not be a problem if we knew the all mighty general width of the <div1>, but we don't, and still we want it this scheme to behave like this: Code: <table width="dynamic"> <tr> <td width="20"></td><td>flexible here</td><td width="20"></td> </tr> </table> So is there some way to do it with divs and css? Dear all I would like to be able to create a design with a text column and an image column. The text would be continuous in the left-hand column, and images would be displayed in the right-hand column. In other words, I would like to be able to use the following HTML: Code: <p>blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah <img src="test.jpg" /> blah2 blah2 blah2 blah2 blah2 blah2 blah2 blah2 blah2 blah2 blah2 blah2 blah2.</p> I would like the text to appear continuously in the left-hand column, while the image appears at the correct point, but in the right-hand column. In other words, I would like the left-hand column (assuming I fixed its width) to contain the output: Code: blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah2 blah2 blah2 blah2 blah2 blah2 blah2 blah2 blah2 blah2 blah2 blah2 blah2. While the right-hand column will have the image, its top lining up with where the text changes to 'blah2'. Any ideas? I realize the most difficult thing about asking this question is describing the visual layout I want to achieve. I shall try to draw a mock-up, and post a link to it in this thread. Many thanks in advance, Tom Hi all, I would like to create a 3 column layout with the left menu, right menu & the content to have the same height always independently which is the longest like this example below. Also I have attached the HTML & CSS for your reference. How can I do this in CSS please? Thanks in advance ziffa27 Example: http://www.pixy.cz/blogg/clanky/css-3col-layout/ Code: <!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>Untitled Document</title> <style type="text/css"> <!-- html, body { margin: 0; padding: 0; } body { background: silver; color: #000000; font-family: 'Arial, Helvetica, sans-serif'; font-size:11px; font-weight:normal; line-height:16px; text-align:left; } #container { background: yellow; margin: auto; padding: 0; width: 1000px; } #header { background: orange; margin: 0; padding: 0; height: 200px; } #left_menu { background: red; margin: 0; padding: 0; width: 200px; float: left; } #right_menu { background: blue; margin: 0; padding: 0; width: 300px; float: right; } #content { background: green; margin: 0; padding: 0; margin-left: 200px; width: 500px; } #footer { background: aqua; margin: 0; padding: 0; clear: both; height: 30px; } --> </style> </head> </head> <body> <div id="container"> <div id="header">Header</div> <div id="left_menu">Left menu</div> <div id="right_menu">Right menu</div> <div id="content">Content<br />Lorem ipsum dolor sit amet, est vitae ut. Risus amet illo mollitia magna erat voluptatem, adipiscing arcu eget cras eu nulla, quam eu nec orci, magna quisque nullam adipiscing integer suspendisse, vulputate hac id vivamus at sed mi. Pede magnis fringilla etiam, tempus vel vitae elementum sed nunc omnis. Praesent condimentum aliquam in eros et, pharetra nam imperdiet corrupti posuere, per suspendisse diam turpis parturient turpis, suscipit semper augue nulla, curabitur ac nisl. Iaculis tempor quam id morbi, sodales nullam nulla, ullamcorper tortor illum hendrerit, wisi fringilla ornare fames in, at ornare luctus eu officia platea.</div> <div id="footer">Footer</div> </div> </body> </html> |