Apologies in advance - I'm a complete Drupal newbie, but I have tried to read the documentation carefully.

I've created a Zen subtheme with a fixed layout. The default 3-column layout has left and right sidebars of 200px width, content of 560px width, and (obviously) a total page width of 960px. What i need instead is for each sidebar to be 160px, the content to be 635px, and the total page width to be 955px.

I edited the layout.css file, replacing all instances of 960px with 955px, 200px with 160px, 760px with 795px, and 560px with 635px. And.. the layout's completely messed up. The left sidebar appears to the right of the content, with the right sidebar right next to it. The navigation bar is offset way to the right: it's aligned with where the left sidebar sits now.

I know it's really important to 'do the math' - i.e. "Negative value of #content's width + left margin" etc - but I thought I'd done that. Clearly I haven't done it properly. :( Can anyone offer any advice? It would be much appreciated. I can obviously post my layout.css if it would help.

Comments

florissantti’s picture

I'm going to guess that you may need to change your position elements. It's usual for extreme weirdness to happen when you change something like that, especially a bunch at once. I find it's best to work on one item at a time. Tune that and then move on to the next item. There is usually a lot going on with regard to overall layout that is affecting may divs farther down the line.

Posting your css and/or the site link would be pretty useful in helping to solve your problem, also.

sionnach’s picture

Many thanks florissantti, that does sound like great advice. I'm posting my layout.css below: any guidance or suggestions will be greatly appreciated. Each line I changed has been commented out. The rest of the subtheme is unchanged from the defaults.

/* $Id: layout-fixed.css,v 1.5.2.3 2009/02/13 19:20:19 johnalbin Exp $ */

/*
 * LAYOUT STYLES
 *
 * Define CSS classes to create a table-free, 3-column, 2-column, or single
 * column layout depending on whether blocks are enabled in the left or right
 * columns.
 *
 * This layout is based on the Zen Columns layout method.
 *   http://drupal.org/node/201428
 *
 * Only CSS that affects the layout (positioning) of major elements should be
 * listed here.  Such as:
 *   display, position, float, clear, width, height, min-width, min-height
 *   margin, border, padding, overflow
 */


/** body **/
  body
  {
  }

  #page,
  #closure-blocks
  {
    /*
     * If you want to make the page a fixed width and centered in the viewport,
     * this is the standards-compliant way to do that. See also the ie.css file
     * for the necessary IE5 hack to center a div.
     */
    margin-left: auto;
    margin-right: auto;
    /*width: 960px;*/
    width: 955px;
  }

  #page-inner
  {
  }

  #navigation-top,
  #navigation
  {
    position: absolute; /* Take the named anchors out of the doc flow    */
    left: -10000px;     /* and prevent any anchor styles from appearing. */
  }

  #skip-to-nav
  {
    float: right;
    margin: 0 !important;
    font-size: 0.8em;
  }

  #skip-to-nav a:link, #skip-to-nav a:visited
  {
    color: #fff; /* Same as background color of page */
  }

  #skip-to-nav a:hover
  {
    color: #000;
    text-decoration: none;
  }

  /* Alternatively, the skip-to-nav link can be completely hidden until a user tabs
     to the link. Un-comment the following CSS to use this technique. */
  /*
  #skip-to-nav a, #skip-to-nav a:hover, #skip-to-nav a:visited
  {
    position: absolute;
    left: 0;
    top: -500px;
    width: 1px;
    height: 1px;
    overflow: hidden;
  }

  #skip-to-nav a:active, #skip-to-nav a:focus
  {
    position: static;
    width: auto;
    height: auto;
  }
  */

/** header **/
  #header
  {
  }

  #header-inner
  {
  }

  #logo-title
  {
  }

  #logo
  {
    float: left;
  }

  #site-name
  {
  }

  #site-slogan
  {
  }

  #header-blocks
  {
    clear: both; /* Clear the logo */
  }

/** main (container for everything else) **/
  #main
  {
    position: relative;
  }

  #main-inner
  {
  }

/** content **/
  #content,
  .no-sidebars #content
  {
    float: left;
    /*width: 960px;*/
    width: 955px;
    margin-left: 0;
/*    margin-right: -960px; /* Negative value of #content's width + left margin. */ */
    margin-right: -955px; /* Negative value of #content's width + left margin. */
    padding: 0; /* DO NOT CHANGE. Add padding or margin to #content-inner. */
  }

  .sidebar-left #content
  {
    /*width: 760px;*/
    width: 795px;
    /*margin-left: 200px; /* The width of #sidebar-left. */*/
    margin-left: 160px; /* The width of #sidebar-left. */
    /*margin-right: -960px; /* Negative value of #content's width + left margin. */*/
    margin-right: -955px; /* Negative value of #content's width + left margin. */
  }

  .sidebar-right #content
  {
    /*width: 760px;*/
    width: 795px;
    margin-left: 0;
    /*margin-right: -760px; /* Negative value of #content's width + left margin. */*/
    margin-right: -795px; /* Negative value of #content's width + left margin. */
  }

  .two-sidebars #content
  {
    /*width: 560px;*/
    width: 635px;
    /*margin-left: 200px; /* The width of #sidebar-left */*/
    margin-left: 160px; /* The width of #sidebar-left */
    /*margin-right: -760px; /* Negative value of #content's width + left margin. */*/
    margin-right: -795px; /* Negative value of #content's width + left margin. */
  }

  #content-inner
  {
    margin: 0;
    padding: 0;
  }

/** navbar **/
  #navbar
  {
    float: left;
    width: 100%;
    margin-left: 0;
    margin-right: -100%; /* Negative value of #navbar's width + left margin. */
    padding: 0; /* DO NOT CHANGE. Add padding or margin to #navbar-inner. */
    height: 3.6em; /* The navbar can have any arbritrary height. We picked one
                      that is twice the line-height pluse 1em: 2 x 1.3 + 1 = 3.6
                      Set this to the same value as the margin-top below. */
  }

  .with-navbar #content,
  .with-navbar #sidebar-left,
  .with-navbar #sidebar-right
  {
    margin-top: 3.6em; /* Set this to the same value as the navbar height above. */
  }

  #navbar-inner
  {
  }

  #search-box
  {
    /*width: 200px;*/
    width: 160px;
    /*margin-right: -200px; /* Negative value of #search-box's width. */*/
    margin-right: -160px; /* Negative value of #search-box's width. */
    float: left;
  }

  #primary
  {
    /*margin-left: 200px; /* Width of search-box */*/
    margin-left: 160px; /* Width of search-box */
  }

  #secondary
  {
    /*margin-left: 200px; /* Width of search-box */*/
    margin-left: 160px; /* Width of search-box */
  }

  #navbar ul /* Primary and secondary links */
  {
    margin: 0;
    padding: 0;
    text-align: left;
  }

  #navbar li /* A simple method to get navbar links to appear in one line. */
  {
    float: left;
    padding: 0 10px 0 0;
  }

  /* There are many methods to get navbar links to appear in one line.
   * Here's an alternate method: */
  /*
  #navbar li
  {
    display: inline;
    padding: 0 10px 0 0;
  }
  */

/** sidebar-left **/
  #sidebar-left
  {
    float: left;
    /*width: 200px;*/
    width: 160px;
    margin-left: 0;
    /*margin-right: -200px; /* Negative value of #sidebar-left's width + left margin. */*/
    margin-right: -160px; /* Negative value of #sidebar-left's width + left margin. */
    padding: 0; /* DO NOT CHANGE. Add padding or margin to #sidebar-left-inner. */
  }

  #sidebar-left-inner
  {
    margin: 0 20px 0 0;
    padding: 0;
  }

/** sidebar-right **/
  #sidebar-right
  {
    float: left;
    /*width: 200px;*/
    width: 160px;
    /*margin-left: 760px; /* Width of content + sidebar-left. */*/
    margin-left: 795px; /* Width of content + sidebar-left. */
    /*margin-right: -960px; /* Negative value of #sidebar-right's width + left margin. */*/
    margin-right: -955px; /* Negative value of #sidebar-right's width + left margin. */
    padding: 0; /* DO NOT CHANGE. Add padding or margin to #sidebar-right-inner. */
  }

  #sidebar-right-inner
  {
    margin: 0 0 0 20px;
    padding: 0;
  }

/** footer **/
  #footer
  {
  }

  #footer-inner
  {
  }

/** closure **/
  #closure-blocks /* See also the #page declaration above that this div shares. */
  {
  }

/** Prevent overflowing content **/
  #header,
  #content,
  #navbar,
  #sidebar-left,
  #sidebar-right,
  #footer,
  #closure-blocks
  {
    overflow: visible;
    word-wrap: break-word; /* A very nice CSS3 property */
  }

  #navbar
  {
    overflow: hidden; /* May need to be removed if using a dynamic drop-down menu */
  }

  /* If a div.clear-block doesn't have any content after it and its bottom edge
     touches the bottom of the viewport, Firefox and Safari will mistakenly
     place several pixels worth of space between the bottom of the div and the
     bottom of the viewport. Uncomment this CSS property to fix this.
     Note: with some over-large content, this property might cause scrollbars
     to appear on the #page div.
  */
  /*
  #page
  {
    overflow-y: hidden;
  }
  */
jdabbott51’s picture

Hey, I had this problem too. I'm a total Drupal newbie as well. After having reset the CSS layout files so many times, I finally figured out a way to work around the serious width issue. Here it is:

Don't choose fixed widths at all. Choose liquid instead. This makes things so much more tweakable you have no idea. And then in the CSS for #page class go ahead and determine the widths and then use margin-left: auto; and margin-right: auto; to center it. This is a very simplified method. If I'm not wrong (and I very well could be) I think zen created all of the negative margins in order to solidify the layout for earlier versions of IE. But in my own experience the "margin: auto;" seems to work just fine on most browsers.

Now. If reading this makes some developers scream in fright then please feel free to correct me. Thanks!

sionnach’s picture

Should have said that I am using Drupal 6. Thanks.