tags:

views:

926

answers:

2

I am using Yahoo's UI Grids to structure most of my pages. One of my pages is a Google map and I need about a 400 pixel fixed left column to put map legend information into. YUI Grids however only offers 3 columns for their 100% page layouts, namely 160px, 180px and 300px.

Is there a way that I can customize their 'template 3' which provides the 300px column to get my 400px column I need?

A: 

There is definitely a way. I think its just a matter of tweaking the CSS to either add in another 400px column, or modifying an existing column to fit your needs. If you are adding another column, be sure to account for the additional width (plus margin) and either reduce width on other elements, or increase the width of your containing element.

If the layout is using 100% width of the browser, width may not be an issue, but if your content is wrapped in a container element which holds all of your columns, be sure to adjust the existing elements to make up for the size of your new column.

EDIT: Also if you are dealing with 100% width layouts, its probably better to size your columns using percentage, instead of a fixed pixel size. Since the containing element for your columns will be the user's screen, if you use percentage then the column sizes should adjust relative to their resolution/window size.

If you want your new column to appear on the left of the your other columns, typically you would place it before the other columns in your markup, and apply a "float:left" property. But, take a look at how the other columns are set up in the YUI CSS, and follow their method.

I hope that helps.

Acorn

Acorn
+1  A: 

I've determined how to do this. Kudos for Nate in the YUI forums for pointing me in the right direction.

To set a fixed left column, you need to divide the column pixel width by 13 to determine the em's for all non-IE browser's. For IE, divide the column width by 13.3333

e.g. wanting a fixed 480px width, 480/13 gives me 36.9231em for non-IE and 480/13.33 is exactly 36em for IE

Using template 3, the CSS is:

.yui-t3 .yui-b {
  float: left;
  width: 12.3207em; *width: 12.0106em;
}

.yui-t3 #yui-main .yui-b {
  margin-left: 36.9231em; *margin-left: 36em;
}

Also, if you want to tweak margin's e.g. zero margin, you can do something like:

#doc3 {
  margin: auto 0;
}

Grids is presently deprecated in YUI 3 - a bit of a shock when I saw that. There will be some browser(s) that drop off the A category in July and as a result, Grids will be reworked given that some of the initial design decisions were based on older browsers of course.

timbo
It's resolved. Could someone flag this please.
timbo
1000+ views later, not a single person has commented or bothered to indicate that this is useful. Sheesh.
timbo