Basic CSS Layout

Robizzle01

Limp Gawd
Joined
Sep 30, 2005
Messages
159
edit: I've made some progress since posting. Please refer to layout3 as 1 and 2 are useless now.

I've been surfing around all day looking at all sorts of templates and tutorials for building css based layouts. I normally hold my own when I'm working on this sort of stuff but I'm truely stumped ... I have quite literally spent the entire day working on this and accomplished nothing. Not even something I can start working from.

I started looking at templates from glish.com and also tried using code from boxes and Blue Robot but nothing is working out for me :(

What i'm trying to do...
First take a look at this. That is what I came up with but for later explained reasons, it wont do the job for me. Let me first explain what I'm trying to accomplish, refer to that link as needed.

I'm trying to make a css based layout with the following properties:
1) wrapper div containing everything that follows, min-width: 600px; max-width: 955px; This div should be centered horizontally (so that users with a window wider than 955px will see it centered.
2) div for banner/logo. All the way to the top left of the wrapper boundries. My Logo will be fairly narrow (small in width) and the background of this div will be a repeat-x that makes the logo look as wide as the page is. To the right of the logo (but on the tiled graphic area) will be two input fields and a submit button for logging into the website.
3) below the banner will be two collumns. the left collumn is set width 200px (or somewhere around there depending on how my content fits.) The right collumn will fill the rest of the screen width. Both of these collumns should grow downward as needed by the ammount of content they contain. If the right collumn contains more information than the left collumn, it is important that it doesn't "wrap" around it. Likewise, if the left collumn is taller than the right, it should not wrap around the right one. This is one problem I had when trying to do the layout using float: left;
4) Below the two collumn area should be a footer where I can have contact us and other such links.

Problems with my working design that I cant for the life of me solve:
a) All divs combine to use 100% of the window space reguardless of contents. The left and right collumns should not be so tall. Also, if either of those collumns had enough information to fill the entire page, the green footer just cuts it them off. I need them to expand as needed and adding a scroll bar.
b) Minimum and maximum widths are not working and I have a feeling that even if they were, centering the wrapper would not work.

I also have a layout2 online here if anyone finds it helpful. This one works okay in firefox and not at all in IE. In firefox it at least has the wrapper, min-width, max-width, and centering working. However, I cant figure out why the blue box is overlapping the yellow (doesn't do this in IE) and why the red box isn't all the way up against the yellow.

If anyone has a link to a site with code they know works, or a fix for my code specifically I am all ears. All these browser incompatabilities are driving me zonkers and I would really appreciate any help or something to get me started in the right direction.


edit:
I made quite a bit of progress burning the midnight oil. Not sure what I even did differently this time it just started to work. I'm still having trouble with the red section wrapping around the blue one, anyone have a fix for this?
Check out the very very rough draft
 
I went ahead and added the doc type and fixed all validation errors (css and xhtml strict.) I'm still having trouble with my main div wrapping around the left menu once it becomes longer.

I've been meaning to ask about javascript. I know most browsers can disable it and some people opt to for steel clad security, but what fraction of the internet users is this? Are they a small enough minority that I can just not be concerned about it? This would be an issue with both checking form input before inserting it into a database and for hacks like the min/max width you were talking about.

Would you recommend using the javascript to fix the min-width and max-with issue with IE would I be better off leaving it alone? It doesn't really hurt anything the way it is except that the divs will always expand to the size of the window -- not what I wanted but at least nothing is "broken".
 
Sorry I still have no time to look at your code. Very busy time of year for me. On the list for tomorrow though...
One thing I can point out really quick - Your first line:
<?xml version="1.0" encoding="utf-8"?>
put IE into quirks mode (same as having no doctype). Pretty sure you don't need it at all, just get rid of it.
<edit>if you do need an xml statement, I don't think you do, it goes somewhere else. As the first line in the document it makes IE render in quirks mode but not when it is where it belongs. I don't know where that would be since I've never needed that statement.</edit>

Also,... have you seen your rounded corner in IE? *.png and IE don't seem to get along. Just make that image a .jpg or .gif and it will work.
The div wrapping the one on the left is easy to fix - ...if you haven't figured it out already by tomorrow I really will have a look at it.
 
Oh thats awesome. Thanks so much for the help Excavator!

As far as I can tell there is nothing screwy with the layout in either IE or firefox. I really appreciate your help. Now I just need to figure out what all you had to change so next time i'm making a layout i dont have to hunt you down -- heh.

As for the png issues, I was sticking with the "build it in firefox, hack it into IE" mindset -- they are only temporary. I still haven't decided on my color scheme yet and changing the background behind the transparent png worked best. The site is going to be mainly a used book swapping grounds for college students at my university and an amazon storefront if I ever finish it. Right now its just a fun project for me to do after I get back from work. But anyways, I'm thinking the green everwhere makes the site look amature. I may opt to go with a white background everywhere and use colors sparingly -- maybe a look similar to the new slashdot design.

Thanks again Excavator, you probably saved me from a few nights of headaches.
 
A couple misc questions. I've copied and modified Excavator's revision to my computer here.

1) In IE my top bar is 15 pixels taller than it should be. I've narrowed this down to a problem with my padding-top: 15px in #topright (the div that contains the login form.) The reason I have the 15px of padding is to keep it centered vertically in the top bar. This works, however, also causes IE to make #top an extra 15px tall even though #top and #topright are both defined to be height: 100px. I tried several variations of margin-top and/or padding-top and nothing seems to work. (for the most part the differences between the two evades me.)

2) Another question about that log in form. I've seen some neat trick where an input box says "enter email" then as soon as the user clicks inside of it, the contents dissapear. Also, the background color of the box was faded out before the click. Digg's search box is a good example. I looked at the source and couldn't figure it out. Is this a javascript trick or whats going on? Also, could I do something similar with my password box or would anything I put inside of it just be displayed as ******? (right now the password box is just a text box, that will have to change at some point.)

3) I've moved the department selection box down below the courses label. In IE there is a blank line between courses and the dropdown box that isn't there in firefox. Not sure what is causing it.

4) I'm still playing around with the colors of everything. #006633 and white are our school colors here but green doesn't tend to look good in most websites so i'm not sure how i'm going to do this. Any suggestions or opinions about my color scheme could be helpful -- i'm always willing to hear other's ideas.

I appreciate everyones input on this. Its nice to be able to bounce some ideas off experienced people :)
 
Your problem in IE in commonplace.

What happens:

You have your 100x100 DIV.

You add your 15px padding. IE improperly puts this padding AROUND your DIV.

Now you have a 130x130 DIV with 100x100 of usable space.

If you add a margin, that goes around the padding.


This is a problem. Padding is supposed to be inside the DIV.

You have your 100x100 DIV.

You add your 15px padding. A compliant browser like Firefox puts this inside your DIV.

You now have a 100x100 DIV, with 70x70 of usable space.


I forget the hacks for it, however somesort of pseudo class would work like first-child.
 
One more thing Robizzle01, with the container set at 1000px anyone with a browser window smaller than that will get a horizontal scrollbar. I would just narrow it up a bit but the min/max width is a good idea too...I've just never had much luck getting it to work.
Here is one hack for it - http://www.svendtofte.com/code/max_width_in_ie/ and I'm sure you can google some more.

This is a problem. Padding is supposed to be inside the DIV.

You have your 100x100 DIV.

You add your 15px padding. A compliant browser like Firefox puts this inside your DIV.

You now have a 100x100 DIV, with 70x70 of usable space.


I forget the hacks for it, however somesort of pseudo class would work like first-child.
Instead of padding the div your text or picture is in, put a margin around the text or picture and let the div size itself accordingly. Much better than using a hack when you don't need to.
 
Wow man, i'm impressed. Your'e a fast learner. Are you just new to CSS or webdesign in general?
 
Teen-Pound said:
Wow man, i'm impressed. Your'e a fast learner. Are you just new to CSS or webdesign in general?

hah, neither. I wish I could say that I just started. I'm just new to designing from scratch. I actually am a computer science undergrad and found a part time job work on our business college's websites and they asked me to stay and work fulltime for the summer -- so I am. I mostly do text updates but they let me wet my beak with some coding projects every now and then -- today I just finished my first project where I had to create a database (to save form input into.)

I've worked with CSS before but mostly only stealing from other sites, stripping out everything I dont need and then changing values to make it look how I want. Or similarly, going to sites that have code snippets, figuring out how they work and going at it -- like mouseover menus using css defined unordered lists for example. The site i'm working on now is the first one that I wrote up from scratch.

I've been toying around with html since middle school but never really had a project to work on and therefor didn't learn much of the fine details and design techniques. Also, since I was self taught (and apparently i'm not a very good teacher) I never learned the stuff about browser compatability. IE's rendition of my page is pretty nasty.

Which brings me to my latest post....

Current working copy of my site can be found here.

I'm still struggling greatly with positioning everything correctly in both firefox and IE. Maybe if someone could help with fixing one of these elements then all of them could be fixed using the same patch/hack? Heres my whats wrong list...

1) In firefox: the "courses" header above the drop down menu on the left should be lined up such that it's top edge is the same altitude as the sentance "I will put content here one of these days". In IE, this seems to be working properly.

2) The drop down menu should be flush against the bottom of "courses". There is white space between the two elements in both IE and firefox, although IEs seems to be twice as wide of a gap.

3) In IE my list of badges is spaced further away from the bottom of the menu than it should be. I'm talking about the "get firefox", "powered by php" etc boxes. They are a correct spacing below the button menu in firefox.

4) And lastly, in firefox my "enter email" and "enter password" boxes are in the top right corner of the #top bar. This is correct given my code, however, in IE they are spaced the way I would actually like them to be. The problem is getting both IE and firefox to look the way that IE does right now.

I tried removing all margin and padding from divs and using only p, ul, ul li, ul li a, input, fieldset, etc for proper alignment using padding but its still not working out.

Cheers to my fellow designers.
 
looks like you are coming close to a design I did for a class project. Only difference was that I had rouned tips on the ends... Looked great and smooth at 1280x when I was designing it...looked rather naughty when viewed at 800x. Do not put rounded tips at the end!!! :p
 
Back
Top