SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Threaded View

  1. #1
    SitePoint Member
    Join Date
    Jun 2006
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    css/3 column tricky problem

    i'm having trouble with this "3 column" layout:

    i need to have a fixed width center col., with the left and right cols flex --- the problem i'm having is keeping the LEFT column floated right so as to maintain the same distance between the right edge of the left column with the left edge of the center (fixed at 770) column regardless of browser res... (please see layout i'm describing in attachment - not sure if my words are clear enough...)

    could someone please show me what i'm doing wrong? i'll include the code i've played with below...

    (i REALLY appreciate it!!)

    Code:
    <title>Untitled Document</title>
    <style type="text/css">
    <!--
    body {
    	font: 100% Verdana, Arial, Helvetica, sans-serif;
    	background: #666666;
    	margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */
    	padding: 0;
    	text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */
    	color: #000000;
    	background-color: #FFFFFF;
    }
    .thrColLiq #container {
    	width: 100%;  /* this will create a container 80% of the browser width */
    	background: #FFFFFF; /* the auto margins (in conjunction with a width) center the page */
    	border: 0px solid #000000;
    	text-align: left; /* this overrides the text-align: center on the body element. */
    	margin-top: 0;
    	margin-bottom: 0;
    }
    /* Tips for sidebars:
    1. Since we are working in percentages, it's best not to use side padding on the sidebars. It will be added to the width for standards compliant browsers creating an unknown actual width. 
    2. Space between the side of the div and the elements within it can be created by placing a left and right margin on those elements as seen in the ".thrColLiq #sidebar1 p" rule.
    3. Since Explorer calculates widths after the parent element is rendered, you may occasionally run into unexplained bugs with percentage-based columns. If you need more predictable results, you may choose to change to pixel sized columns.
    */
    .thrColLiq #sidebar1 {
    	float: none; /* this element must precede in the source order any element you would like it be positioned next to */
    	width: 13%; /* top and bottom padding create visual space within this div  */
    	padding-top: 15px;
    	padding-right: 0;
    	padding-bottom: 15px;
    	padding-left: 0;
    	margin-left: auto;
    }
    .thrColLiq #sidebar2 {
    	float: right; /* this element must precede in the source order any element you would like it be positioned next to */
    	width: 10%; /* top and bottom padding create visual space within this div  */
    	padding-top: 15px;
    	padding-right: 0;
    	padding-bottom: 15px;
    	padding-left: 0;
    }
    .thrColLiq #sidebar1 p, .thrColLiq #sidebar1 h3, .thrColLiq #sidebar2 p, .thrColLiq #sidebar2 h3 {
      margin-left: 10px; /* the left and right margin should be given to every element that will be placed in the side columns */
      margin-right: 10px;
    }
    /* Tips for mainContent:
    1. the space between the mainContent and sidebars is created with the left and right margins on the mainContent div.
    2. to avoid float drop at a supported minimum 800 x 600 resolution, elements within the mainContent div should be 300px or smaller (this includes images).
    3. in the Internet Explorer Conditional Comment below, the zoom property is used to give the mainContent "hasLayout." This avoids several IE-specific bugs.
    */
    .thrColLiq #mainContent {
    	width:770px;
    	margin-top: 0;
    	margin-bottom: 0;
    	margin-left: auto;
    	border: 1px dashed #000000;
    	margin-right: 0px;
    }
    /* Miscellaneous classes for reuse */
    .fltrt { /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */
      float: right;
      margin-left: 8px;
    }
    .fltlft { /* this class can be used to float an element left in your page The floated element must precede the element it should be next to on the page. */
      float: left;
      margin-right: 8px;
    }
    .clearfloat { /* this class should be placed on a div or break element and should be the final element before the close of a container that should fully contain its child floats */
      clear: both;
      height: 0;
      font-size: 1px;
      line-height: 0px;
    }
    -->
    </style>
    <!--[if IE]>
    <style type="text/css"> 
    /* place css fixes for all versions of IE in this conditional comment */
    .thrColLiq #sidebar2, .thrColLiq #sidebar1 { padding-top: 30px; }
    .thrColLiq #mainContent { zoom: 1; padding-top: 15px; }
    /* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */
    </style>
    <![endif]--></head>
    
    <body class="thrColLiq">
    
    ////////////////////////////////////////////////
      <div id="container">
        <div style="width:75%"> 
          <div id="sidebar" style="float:left; width:25%; height:150px; text-align:right;">Left</div>
          <div id="main" style="float:right; width:770px; border:1px solid #000;">
            <h1> Main Content<br />  
              <br />  
              <br />  
              <br />
          </h1>
          <p>&nbsp;</p>
          <!-- end #mainContent -->
            </div>
        </div>
    	<!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats -->
        <br class="clearfloat" />
    <!-- end #container --></div>
    </body>
    </html>
    (I'm using the inline code in experimentation - i realize it's a bit sloppy at the moment.)

    thanks for anyone's help ...

    Regards,
    GN
    Attached Images Attached Images


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •