fixed width, 2 column CSS layout problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ed

    fixed width, 2 column CSS layout problem

    The page I'm working on is at http://www.coldpizzasoftware.com/temp/layout.html

    I trying to get the yellow sidebar to go in the white area to the right
    of the green content area and between the blue header and footer. Does
    anyone know how to do?

    I know I can add float: left; to the content div and it sort of works,
    but it doesn't seem right either. In this case the content div and the
    side bar div will no longer stay in their container, the page div,
    instead they will overlap the bottom of their container.

    I've read several similar threads on this newsgroup and still can't
    figure it out. I've googled for a solution too, and I've found several
    examples CSS layouts, but none that are similar enough to what I'm
    attempting. I know of several sites that use a similar layout and I've
    tried stripping them down to the bare bones layout, but each time I've
    tried I've screw it up.

  • Jim Moe

    #2
    Re: fixed width, 2 column CSS layout problem

    Ed wrote:[color=blue]
    > The page I'm working on is at
    > http://www.coldpizzasoftware.com/temp/layout.html
    >
    > I trying to get the yellow sidebar to go in the white area to the right
    > of the green content area and between the blue header and footer. Does
    > anyone know how to do?
    >[/color]
    Replace:
    #sidebar {
    background-color: lightyellow;
    border: thin solid gray;
    position: absolute;
    left: auto;
    right:0;
    width: 210px;
    }

    With:
    #sidebar {
    background-color: lightyellow;
    border: thin solid gray;
    width: 210px;
    float: right;
    }

    --
    jmm dash list (at) sohnen-moe (dot) com
    (Remove .AXSPAMGN for email)

    Comment

    • Rincewind

      #3
      Re: fixed width, 2 column CSS layout problem

      On Tue, 30 Aug 2005 15:24:42 -0700, Ed wrote:
      [color=blue]
      > The page I'm working on is at http://www.coldpizzasoftware.com/temp/layout.html
      >
      > I trying to get the yellow sidebar to go in the white area to the right
      > of the green content area and between the blue header and footer. Does
      > anyone know how to do?
      >
      > I know I can add float: left; to the content div and it sort of works,
      > but it doesn't seem right either. In this case the content div and the
      > side bar div will no longer stay in their container, the page div,
      > instead they will overlap the bottom of their container.
      >
      > I've read several similar threads on this newsgroup and still can't
      > figure it out. I've googled for a solution too, and I've found several
      > examples CSS layouts, but none that are similar enough to what I'm
      > attempting. I know of several sites that use a similar layout and I've
      > tried stripping them down to the bare bones layout, but each time I've
      > tried I've screw it up.[/color]

      Take a look at http://www.positioniseverything.net/ they might be able to
      help!

      Comment

      • Rincewind

        #4
        Re: fixed width, 2 column CSS layout problem

        On Tue, 30 Aug 2005 15:24:42 -0700, Ed wrote:
        [color=blue]
        > The page I'm working on is at http://www.coldpizzasoftware.com/temp/layout.html
        >
        > I trying to get the yellow sidebar to go in the white area to the right
        > of the green content area and between the blue header and footer. Does
        > anyone know how to do?
        >
        > I know I can add float: left; to the content div and it sort of works,
        > but it doesn't seem right either. In this case the content div and the
        > side bar div will no longer stay in their container, the page div,
        > instead they will overlap the bottom of their container.
        >
        > I've read several similar threads on this newsgroup and still can't
        > figure it out. I've googled for a solution too, and I've found several
        > examples CSS layouts, but none that are similar enough to what I'm
        > attempting. I know of several sites that use a similar layout and I've
        > tried stripping them down to the bare bones layout, but each time I've
        > tried I've screw it up.[/color]

        It was bugging me so try this, let me know if it is what you were after

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

        <html>
        <head>
        <title></title>
        <link rel="stylesheet "
        href="testdiv.c ss"
        type="text/css">
        <meta name="Generator "
        content="TextPa d 4.7">
        <meta name="Author"
        content="">
        <meta name="Keywords"
        content="?">
        <meta name="Descripti on"
        content="?">
        <meta http-equiv="content-type"
        content="text/html; charset=us-ascii">
        <style type="text/css">

        #page{
        background-color:#fff ;
        width: 760px;
        margin: 20px auto;
        }
        #header{
        background-color:#6cf ;
        width:100%;
        float: left;
        }
        #footer{
        background-color:#6cf ;
        width: 100%;
        position: relative;
        float: left;
        }
        #content{
        margin: 0 30% 0 0;
        border: 1px solid #000;
        padding: 0 10px 10px ;
        }
        #sidebar{
        width: 30%;
        background-color: #ff9;
        float: right;
        }
        </style>
        </head>

        <body>
        <div id="page">
        <div id="header">
        <h1>The page title here</h1>
        </div>

        <div id="sidebar">
        <ul>
        <li>Item 1</li>

        <li>Item 2</li>

        <li>Item 3</li>
        </ul>
        </div>

        <div id="content">
        <p>this is the content box that goes on and on and on
        and on and on and on and on and on and on and on and on
        and on and on and on and on and on and on and on and on
        and on and on and on and on and on and on and on and on
        and on and on and on and on and on and on and on and on
        and on and on and on and on and on and on and on and on
        and on and on and on and on and on and on and on and on
        and on and on and on and on and on and on and on and on
        and on and on</p>
        </div>

        <div id="footer">
        <p>This is the footer and stuff</p>
        </div>
        </div>
        </body>
        </html>

        Comment

        • Ed

          #5
          Re: fixed width, 2 column CSS layout problem

          On 2005-08-30 16:20:10 -0700, Jim Moe <jmm-list.AXSPAMGN@s ohnen-moe.com> said:
          [color=blue]
          > #sidebar {
          > background-color: lightyellow;
          > border: thin solid gray;
          > width: 210px;
          > float: right;
          > }[/color]

          That, for some reason, doesn't work unless I put the sidebar div before
          the content div in the html and I don't want to do that. The solution
          is definitely to use float though, so thanks.

          Comment

          • Ed

            #6
            Re: fixed width, 2 column CSS layout problem

            On 2005-08-31 04:52:56 -0700, Rincewind <the_rincewind@ hotmail.com> said:
            [color=blue]
            > It was bugging me so try this, let me know if it is what you were after[/color]

            That's is what I'm after. I was trying to avoid having to put the
            sidebar before the content in the HTML, but if I must then I must. It
            seems strange to me that this would make any difference at all, but it
            makes all the difference. Thank you.

            As a side question does anyone know why CSS doesn't allow you to do
            something like the following:

            #sidebar {
            top: #content.top;
            left: #content.right;
            }

            That makes infinitely more scene to me and would simplify most all
            layouts IMHO.

            Comment

            • kchayka

              #7
              Re: fixed width, 2 column CSS layout problem

              Shawn Wilson wrote:
              [color=blue]
              > What you're trying to accomplish is called a 'faux' layout[/color]

              Who besides you calls it 'faux'? I have never heard of such a thing, and
              I've been around here for a long time. Regardless, a JavaScript solution
              is no solution, at least for many people. In most cases, JS isn't
              necessary anyway.

              And quit posting attachments, especially binaries. This is a text-only
              newsgroup.

              --
              Reply email address is a bottomless spam bucket.
              Please reply to the group so everyone can share.

              Comment

              • Jim Moe

                #8
                Re: fixed width, 2 column CSS layout problem

                Ed wrote:[color=blue]
                >
                > That, for some reason, doesn't work unless I put the sidebar div before
                > the content div in the html and I don't want to do that.
                >[/color]
                Well, yes, of course. "float" is the equivalent of "align" for <img>
                and causes an element to act in a similar manner.
                What is wrong with correctly ordering the elements to achieve your
                target design?

                --
                jmm dash list (at) sohnen-moe (dot) com
                (Remove .AXSPAMGN for email)

                Comment

                • Ed

                  #9
                  Re: fixed width, 2 column CSS layout problem

                  On 2005-09-01 00:20:21 -0700, Jim Moe <jmm-list.AXSPAMGN@s ohnen-moe.com> said:
                  [color=blue]
                  > Ed wrote:[color=green]
                  >>
                  >> That, for some reason, doesn't work unless I put the sidebar div before
                  >> the content div in the html and I don't want to do that.
                  >>
                  >> What is wrong with correctly ordering the elements to achieve your
                  >> target design?[/color]
                  >[/color]
                  Well, nothing, that is, if all I'm trying to achieve is a visually
                  appealing page. It's, however, my understanding that the point of
                  designing with XHTML and CSS is so that you can layout the HTML
                  semantically and then apply a style sheet to make it look great.

                  Since I'm of the opinion that the content of the page is significantly
                  more important than the navigation, I have the the content to the left
                  of the navigation and semantically the the content should come before
                  the navigation. Of course this assumes the use of a western (left to
                  right) language. Should my site ever need to support a right to left
                  language, I would apply a separate style sheet, so that the content
                  would be on the right side and navigation on the left, thus adhering to
                  the conventions of that language. In the HTML the semantic order would
                  be preserved, so that the content came before the navigation.

                  Undoubtedly, the particular website I'm working on working on will
                  never need to support this, but I'd like to get in the habit of doing
                  things, in my opinion, correctly.

                  Thanks to Rincewind's and your reply I have my layout working both
                  visually and semantically, with only one minor annoyance. If I can't
                  figure it out soon, I'll most likely chime in with a new questions.


                  Comment

                  • Jim Moe

                    #10
                    Re: fixed width, 2 column CSS layout problem

                    Ed wrote:[color=blue][color=green][color=darkred]
                    >>>
                    >>> That, for some reason, doesn't work unless I put the sidebar div
                    >>> before the content div in the html and I don't want to do that.
                    >>>
                    >>> What is wrong with correctly ordering the elements to achieve your
                    >>> target design?[/color]
                    >>[/color]
                    > Well, nothing, that is, if all I'm trying to achieve is a visually
                    > appealing page. It's, however, my understanding that the point of
                    > designing with XHTML and CSS is so that you can layout the HTML
                    > semantically and then apply a style sheet to make it look great.
                    >[/color]
                    Okay. Float both content and sidebar; content, float:left; sidebar:
                    float:right. Then it does not matter which comes first. And you can swap
                    positions by changing the float direction. Be sure to clear:both in the
                    footer.
                    Floating both divs works as long as both are a fixed width, or both are
                    a percentage width (totaling less than 100%). Otherwise one may wrap below
                    the other.

                    --
                    jmm dash list (at) sohnen-moe (dot) com
                    (Remove .AXSPAMGN for email)

                    Comment

                    • Shawn Wilson

                      #11
                      Re: fixed width, 2 column CSS layout problem

                      "kchayka" <usenet@c-net.us> wrote :[color=blue]
                      > Shawn Wilson wrote:
                      >[color=green]
                      >> What you're trying to accomplish is called a 'faux' layout[/color]
                      >
                      > Who besides you calls it 'faux'? I have never heard of such a thing, and
                      > I've been around here for a long time. Regardless, a JavaScript solution
                      > is no solution, at least for many people. In most cases, JS isn't
                      > necessary anyway.[/color]

                      Well, I didn't call it anything until a few weeks ago when I heard that term
                      and then did a google search for it and found out that the wold calls it
                      that. Maybe it's a crossover from print layout, I don't know, but it's
                      definately the term to search for this layout. Everything that's been
                      pointed out here is in one google search... 'faux columns with css'

                      A search for '3 column layout with css' gets 223,000 results, while 'faux
                      columns with css' only gets 10,100 - but the faux search only returns
                      results for exactly the layout problems and solutions that we're talking
                      about here. The '3 column layout with css' search finds many things that
                      match as well, but many that do not.

                      I just started using that term when I found that a search for it returned
                      exactly what I was looking for, that's all.

                      --
                      Shawn Wilson


                      Comment

                      Working...