Skip to main content
gamedev.net
🔒 Locked

[web] CSS layout

Started by jbadams Jan 15, 2005 at 10:15 AM 3 replies 800+ views
Original Post
jbadams
jbadams
I'm trying to do a nice CSS layout for a small site I'm working on, but I'm having a few issues. Firstly, my code so far:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
  <head>
    <title></title>

    <style type="text/css" media="screen,projection">
    <!--
      body {
           margin: 0px;
           padding: 0px;
           }
      div#banner {
           height: 120px;
           }
      div#leftbar {
           float: left;
           width: 120px;
           height: 100%;
           }
      div#main {
           }
    -->
    </style>
  </head>

  <body>
    

    
leftbar!
main!
also in main!
also in main!
</body> </html>
Alright, so the 'content' of it so far is just so I can see where things are going. I did have borders on everything for this purpose, but I removed them when I discovered they were actually causing a slightly different behavior with some of the things I was trying. If you need a clearer idea of the layout, adding some borders back in temporarily may help. Anyways, onto my problem... The top area (div#banner) is just fine, and the others have gone below it. Below this should be a 2-panel area, with a small menu bar (div#leftbar) running down the left of the main content area (div#main). I've floated the menu bar to the left, and this works fine, it sits on the left of the page, and content of the main div flows around it. However, the menu bar's height is being automatically set to that of it's content, and I want it to be the full length of the main div next to it (which will depend on the content on each page). This can be achieved by setting a pixel value for the height of the div, but then I have to set it for each individual page, and if the content is altered it would have to be manually edited (I plan to make the stylesheet external once it's working btw). Is there any way I can get the leftbar to automatically match the height of the main content area? I'd get this behavior for free with a table layout, but I'd really rather not use one. Thanks in advance for any help/advice. [smile]
- Jason Astle-Adams
jbadams
jbadams
Well, the discussion linked wasn't particularly helpful for my situation except for the fact that 'faux columns' were mentioned. A quick search with google turned up this article, and it seems like I may be able to make use of this technique to achieve my layout, although I'm yet to try it. Thanks for the link in any case.

Any further thoughts/information on the topic would still be welcome, I'm off to try the faux columns trick.
- Jason Astle-Adams
Sander
Sander
The basics is pretty mich that you do float: right on the contents instead of float: left on the menu. From there on it's just prettying things up. An easy way would be:



float: right the main area and give #wrapper and #leftbar the same background.
jbadams
jbadams
I'd actually come up with this myself after some further experimentation when the Faux Columns trick turned out not to be exactly what I'd wanted (although it is very useful). Thanks for help. [smile]
- Jason Astle-Adams

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.