+ Reply to Thread
Results 1 to 6 of 6

Thread: Positioning and Arrangement using CSS

  1. #1
    lostcommander's Avatar
    lostcommander is offline x10Hosting Member lostcommander is an unknown quantity at this point
    Join Date
    Apr 2009
    Location
    United States of America
    Posts
    52

    Question Positioning and Arrangement using CSS

    Hello. I am relatively new to CSS and am trying to rework my site so all the formatting is in CSS. Currently the page layout is done using tables, but it is not quire working correctly because the widths are not correct.

    I would like the header/top of the page to be logo, banner over tabbed navigation, then login/user info (4 sections total).

    With tables, the logo cell width is too large, even though I set the cell width in CSS to be 256px and the logo image itself is 256x128 px. min-width did not work either.

    I then tried changing all the cells to DIVs and positioning everything using CSS, but floating logo left and user info right made them hang down past the banner+navigation.

    http://www.vrexchange.com/trade/index.php?page=search

    Any help, tips, or links to some good reading on CSS positioning would be nice. I have already read through the w3schools.com stuff and a few other pages, but I clearly still do not understand it well enough to reliably apply it. :dunno:

  2. #2
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Positioning and Arrangement using CSS

    Quote Originally Posted by lostcommander View Post
    Any help, tips, or links to some good reading on CSS positioning would be nice.
    Start from scratch. It's usually less work and produces better results. Remember, HTML is supposed to define the structure of a document; if you rewrite a document containing presentational HTML, chances are it will be reflected in the rewritten page's structure.

    Once you've structured the page, write the style sheet. Sometimes you'll need to add additional elements for style rules to target (usually wrapper elements).

    CSS doesn't mean get rid of tables completely. The trade data you're displaying is tabular data, so keep that in a table.

    Before getting in to positioning, make sure you understand the W3C box model. John Hicks created a 3D box model diagram (interactive version) that pretty much shows it all.

    Vandelay Design has this rather large list of CSS resources. I can't speak to the quality of all of the sites listed, but it has the big ones (A List Apart, Quirksmode, Position Is Everything, CSS Zen Garden &c).
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  3. #3
    marshian's Avatar
    marshian is offline x10 Elder marshian is an unknown quantity at this point
    Join Date
    Jan 2008
    Location
    Belgium
    Posts
    526

    Re: Positioning and Arrangement using CSS

    I then tried changing all the cells to DIVs and positioning everything using CSS, but floating logo left and user info right made them hang down past the banner+navigation.
    Floating divs are a good approach!
    I'll give you a very useful tip:
    HTML Code:
    <div style="float: left; width: 200px; height: 100px; background: yellow;"></div>
    <p>This is a paragraph of text.</p>
    This will show the div next to the text. (Try it!)
    HTML Code:
    <div style="float: left; width: 200px; height: 100px; background: yellow;"></div>
    <div style="clear: both;"></div>
    <p>This is a paragraph of text.</p>
    This will show the floated div and the text starts below it.

  4. #4
    lostcommander's Avatar
    lostcommander is offline x10Hosting Member lostcommander is an unknown quantity at this point
    Join Date
    Apr 2009
    Location
    United States of America
    Posts
    52

    Re: Positioning and Arrangement using CSS

    Quote Originally Posted by misson View Post
    CSS doesn't mean get rid of tables completely. The trade data you're displaying is tabular data, so keep that in a table.
    I did know that, but a lot of people seem to miss it, so it is worth repeating, thanks.

    I knew the box model as well, but that 3D CSS box model image confirms it and really helps visualize all the parts of it.

    That list of CSS resources should come in handy once I have a better idea of what I am looking for!

    For the benefit of anyone else trying to learn this, I found the following like informative:
    http://www.barelyfitz.com/screencast...s/positioning/

    and this one makes it a lot easier to write some test formatting code to see what stuff ends up where with what settings:
    http://www.w3schools.com/Css/tryit.a...ition_relative

  5. #5
    xav0989's Avatar
    xav0989 is offline Community Public Relation xav0989 is just really nice
    Join Date
    Jul 2008
    Location
    ifk
    Posts
    4,438

    Re: Positioning and Arrangement using CSS

    The first link you provided was in fact very useful. I learned a couple tricks that I didn't know! guess I'll sleep not so dump tonight!
    Xavier L | Community Public Relations Manager (Free Hosting Support)
    █ Yes, my position is too cool to even exist!
    How am I helping? Rate this post by clicking the icon below! (this is even better than "liking" a post)
    Terms of Service | Acceptable Use Policy | x10Hosting Wiki

  6. #6
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    auto-clearing

    There's another neat little trick to make a parent contain floats: setting 'overflow' on the parent. No non-semantic elements needed. Setting overflow can have other affects; your mileage may vary.

    There's also auto-clearing, which is pure CSS but more verbose and requires support for the :after pseudo-class. lte IE7 don't support :after, but have their own auto-clearing behavior, so lack of :after support isn't an issue.
    Last edited by misson; 10-10-2009 at 09:19 PM.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

+ Reply to Thread

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers