Hacking Blix CSS: From Fixed Width to Fluid

This site uses a modified version of the Blix theme. The most notable modification is the change from fixed width to a fluid layout. I often receive questions on how I did it. Here is a quick tutorial. As you will see, the process is quite easy.

The first step is getting a general idea of how the structure of the page is organized. Blix has an overall div container named #container, in which there are 2 div containers, #content for the main content, and #subcontent for the sidebar.

Fixed width themes specify container width values in pixels. So the next step is locating those lines. When doing a simple search for "width:", you will find the following pieces of code:

#container {
  width: 690px;
}
/* ... */
#content {
  width: 455px;
}
/* ... */
#subcontent {
  width: 205px;
}
(I removed the extra code for brevity)

To switch to fluid layout, you need to specify width in relative values (percents):

#content {
  width: 70%;
}
/* ... */
#subcontent {
  width: 25%;
}
(I left #container's width unspecified to make it take the whole page's width (100%))

That's it. Next, I did some cosmetic changes to fix background colors and images, below is a working patch for the Drupal 4.6 version of Blix. It only patches style.css and should be all what you need to switch Blix from fixed width to a fluid layout.

It's worth noting that modifying other themes to a fluid layout may need more work, especially those which use absolute positioning.

Hope this helps Blix users.

AttachmentSize
fluid-blix.patch.txt1.34 KB
Tags:
Submitted by Ayman on Wed, 2006/05/03 - 12:15am

يوسف (not verified) | If you want to see your | Wed, 2006/05/03 - 1:20pm

Click here if you want to see your website easily in RTL.

Anonymous (not verified) | Thank you very, very much | Tue, 2006/10/10 - 9:41pm

I wasted hour after hour trying to adjust the BLIX theme to my needs - not understanding the underlying structure, which means I misunderstood the overall container as being the content element... Thank you very much for your very clear explanations on that!

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <strike> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <sup> <sub> <h1> <h2> <h3> <b> <i> <u>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

About

Ayman Hourieh

I'm a Computer Science graduate, an Open Source enthusiast, and a Googler.

I'm 24 years old, and live in Dublin, Ireland.

This is my personal blog. The views expressed on these pages are mine alone and not those of my employer.

More

Books

Learning Website Development with Django

Learning Website Development with Django
A beginner's tutorial to building web applications, quickly and cleanly, with the Django application framework.

My first book. Published by Packt Publishing in April 2008.

Icons

Get Firefox!
Drupal.org
Linux
Gentoo
Creative Commons License