treehouse : what would you like to learn today?
Web Design Web Development iOS Development

[Solved] Noobie Layout Question

  • Hi all,

    I'm busy with my first completely sprite-based layout. Wow, what a ride...

    I have a layout in a wrapper div which looks like this:

    http://www.isochronous.net/images/layout.png

    There's a #header div and a #footer div with a #content div between them. The #content div is going to have two pillars to the left and right sides, but I'd like #pillar-top-left and #pillar-top-right to "stick" to the header and #pillar-bottom-left and #pillar-bottom-right to "stick" to the footer. However, I'm not sure how to do this or whether it's even possible. Any ideas?

    Thanks a lot for your help!
  • As a fellow beginner web designer are you sure you want that? What purpose is having all that empty space in between the two pillers on the sides instead of having the empty space between the bottom pillers and the footer?
  • This is very possible, but in the end it isn't going to look appealing to a site visitor.
  • Haha, it's just a diagram... Maybe I should show you guys the actual design.

    http://www.airtimeproductions.co.za/sites/isochronous/index.html

    The "pillars" divs should actually seem part of the footer, but I'm not sure how to pull this off in the CSS.

  • I like the design. I don't think you should be coding it like you've presented in your first post. You don't need to have the pillar divs.

    The footer might be a little trickier.

    This design is a perfect example of why we need to be able to add two different backgrounds to one element!
  • @TheDoc

    Thanks. Looks like I've got my work cut out for me though. What do you suggest by way of another way of coding it?

    Here's the site as it currently stands: http://www.isochronous.net/template.html

    Currently, the header pillars work fine as they are, but aligning the bottom pillars are another story.
  • I wouldn't make each nav item an image, I'd make the entire header have one single background and I would use HTML text for the nav. You can fancy up the font with different services, but it's a much better way to go.
  • The problem with that is that the different nav buttons are of different lengths. I know it works great, like in the header of CSS-Tricks itself, but I'm committed to the current design, I'm afraid.

    Any thoughts on how to pull off the footer and header layout without using the "pillars"?
  • Why does it matter what lengths the nav items are in this case?
  • Basically, because of the sprite menu and the rollover effects involved. I'd prefer to keep it that way.
  • I stand corrected. I dig that design! ;)
  • Cheers guys... I wish I could put it together without breaking my brain, though!
  • Why can't you use a body background of black, and then have two divs with a background image stick to the top and bottom and have the black background your scrolling background for the long pages? Then use another wrapper div for the middle content and have it on top of the 'background' divs?

    This is just first glance and might not make sense, or I might not be explaining it very good.

    Hope it works out for you.
  • Eeesh... Rudy, I follow you until about the middle of the first sentence! Sorry.

    I'm getting quite far with the layout, but those pillars are still bugging the heck out of me:

    http://www.isochronous.net/template.html

    I've now wrapped #pillar-top-left and #pillar-bottom-left in #pillar-left, and the same for #pillar-right, floated the two pillar wrappers left and right and I'm trying to do it with absolute positioning.

    Actually, I remember now that when I was still working as a web designer at an agency, I was sending the developers layouts like this and they'd be pulling their hair out by the end of the day and the design just never got implemented properly. I'm now getting a taste of my own medicine, it seems. Should I be worried?
  • I realize its a bit hard to explain, but hopefully this diagram will help a bit.
  • This is really getting frustrating now. I'm setting #pillar-left and #pillar-right to "position:relative" and the bottom pillar bits to "position:absolute; bottom:0", and by all accounts this SHOULD work, but instead they're displayed halfway down the page.

    The reason for this is that the pillars both have a height of "height:100%", meaning they take their height from the #mid div... which is exactly 0. Uh... what?

    As I understand it, the #mid div should take the height of the content inside it... i.e., the content of #content. But it doesn't. It's just "0".

    Could really use some help from some wise CSS ninjas. :(

    @rudynorman:

    Ah, I see what you mean now. Unfortunately, it's not going to suit my purposes... that space isn't black in the design; it's got a tiling graphic running down it. Thanks, though.

  • Okay, another thing I just noticed:

    The pillar-bottom divs don't stay in the same place all the time. When you resize the browser window, they shift up or down with it. WTF?

    I've checked Firebug and it seems that the #pillar-left and #pillar-right divs change their height value when you resize the window. I have NO clue why this is happening... both are set to "height: 100%; position:relative; float:left"!
  • i always have trouble with height 100% i don't really trust it so don't often use it. If i hover over your #mid element in firebug it's much smaller then it should be considering the #content extends right down to the bottom of the page. And because the pillars are taking their height from the #mid section i guess this is why there not going to the bottom.

    I think this is happening because of the three child elements inside the #mid element are all floated, have you heard of the clearfix (http://css-tricks.com/snippets/css/clear-fix/) method? applying it to your #mid element might just sort it out.
  • I've suspected that it might be because of the floats as well.

    I hadn't heard of the clearfix method, and I tried it, but no luck. Thanks anyway, ralc.
  • ah i see at least your #mid element now registers its height to the bottom of the page. But the 100% height on pillars still is'nt working.

    (ive made a demo of the explanation below: http://ralcus.com/band/ )

    Ok how about a change in tactics, instead of having the two pillars either side you could lose them, just make the #content div take the full width, give it a border on the left and right of 1 pixel of that brown for the outer border. Then making another div inside the #content div and give that another 1 px brown left and right border for the inner part of the colum. pad out #content by 48pixels on the left and right and make sure your inner div has the 20 pixel padding for left and right.

    At this point you would have the borders running the full width of the page, now you just need to put the tops and bottoms of the pillars in place. Instead of having two pillar divs with the tops and bottoms inside how about taking the tops and bottoms out and placing them on their own leaving you with four divs ( pillar-left-top, pillar-right-top, pillar-right-bottom, pillar-left-bottom ) inside the #mid element.

    Now what you could do is position them by taking them out of the flow of the document so they don't interfer with the #content div. To do this you can position each one absolutely. Positiong something absolutely will by default position them relative to the browser view port. But the extremely handy thing is, if a parent element is positioned relative any child elements positioned absolutely will now be relative to them rather then the browser view port. So putting position:relative on the #mid div allows you to position each of the four pillar divs in the top-left, top-right, bottom-left and bottom-right position of the #mid div without disturbing the #content div.
  • Wow! I'd never have seen that solution. That's amazing!

    It looks great and I'm busy implementing it now. Thanks a lot for your help!

    My only worry is how cross-browser compatible it is, since it's a rather roundabout way of doing things. I've checked in all current versions of Firefox, Chrome, Safari and Opera, but I don't have a Windows machine here and I just KNOW IE is going to ruin the party.
  • How about this -

    the grouping isn't the greatest but - move the pillar-left-bottom and pillar-right-bottom directly into the #mid div. Give #mid position:relative; and then use absolute positioning on the pillar-bottom divs and set their bottom to 0

    The pillar wrapper divs do not have the full height of #mid, but if you look at the size of mid, it is the perfect size for what you want to do, the pillars will always be at the bottom of the post list
  • Hi Jason,

    Thanks man, I tried that as well actually, but I realised that I couldn't accommodate for the borders running down the sides. I'll stick with ralc's solution for now.

    Before I mark this solved, I have another side-question... The links in my sprite navs aren't working. I'm guessing this is because I assigned the graphics to the "li" elements and not to the "a" elements (didn't want to disobey the block/inline rule). How can I fix this?

    Thanks everyone.
  • Also, for the comments section:

    I'd like to connect a little arrow to the comment pointing to the poster's avatar to make it a speech bubble (my design: http://www.airtimeproductions.co.za/sites/isochronous/index.html ). What is the best way to go about this?
  • regarding the the links, they appear to be missing if you inspect them with firebug, or at least a width and height isn't registering. If you display block the links and then inspect them with firebug you will see that they now appear and are the correct width, now all you have to do is specify their height.
  • for the speech bubbles i would use a similar method to the pillar tops and bottoms. position:relative on each of the speech bubbles ( .comment .text ) and then place a div inside them with the arrow as a background image and with absolute positiong to get it in the correct place.
  • i wondered why the button text wasn't showing when i was disabling the background images in firebug and then noticed the text-indent:-9999px, thats a good trick i've never thought of doing that.

    I noticed that by placing the background images on the li tags your then using the :hover pseudo class on them to change the image. I think you could just put the background images on the anchor tags instead. It's ok to have block elements inside block elements so using the anchor tags to apply the backgrounds and displaying them block is fine. This way your image rollover effects will also work in ie6 which doesnt support the :hover pseudo selector on anything except the anchor tag
  • I've assigned a class "spritenav" to the ul elements in the sprite navs and have added this CSS:

    .spritenav { padding:0; }
    .spritenav li a {display: block;}


    Hover, it doesn't seem to have worked. At least for the header and footer navs - the social media links work.
  • this should sort out your top nav links
    #nav-top a{ display:block; height:83px }
  • The text-indent trick is quite widely-used in sprite navs, as far as I know. The advantage is that it doesn't hide the text (the way "display:none" would do), so it's in a sense more SEO-friendly... although it does also try to "fool" the search engines in a way. I'm not sure whether it's detrimental either way.

    Thanks, that did the trick... I'll have to reposition them, but the rollovers and the links work. Tomorrow, though. *yawn*

    Again, thanks for all your help!
  • I actually took the time to fix all the layout errors. It's more or less finished now. Sweet!

    Thanks to everybody who helped out — this sucker's now solved.