
BigfootCSS is a 22k uncompressed / 6k compressed CSS stylesheet that can be used to aid you in the styling of your web pages. It is a collection of real world CSS classes, box model fixes, generic classes for various common styles, standard Ad sizes, and a solid browser reset based on Eric Meyer’s CSS reset. It can be applied to the whole page, or it can simply be applied to a particular element within the page and its children. This latter option is very useful for CMS module development as it makes it easy to style just your module without being affected by or affecting the host page.
If you have written a module that sits inside of DotNetNuke, WordPress, Jumla, etc. you know what I mean. You can’t control the skin in which your module runs, but you have to provide a reasonable amount of protection to ensure the proper layout of your module. You must also be a good citizen of the ecosystem and not allow your styles to bleed into the rest of the skin. BigfootCSS solves this problem very easily by only targeting elements with a certain id.
Why?
Over the years I have used a number of CSS frameworks. In them I found a lot of good techniques, and others… well not so great. So I started creating my own CSS bag of tricks, I’m not sure I would call it a framework, but rather a collection of real world CSS classes, hacks, and fixes. Most of the tools in this toolbox come from everything I’ve liked about the other frameworks I’ve used, most of the credit goes the guys that have figure out the different hacks to fix the IE box model, to create a proper reset, etc. I’ve lovingly named this compilation of ideas bigfootCSS.
Context in which I use bigfootCSS:
1. I’m a developer creating business apps, not just websites. A lot of the utility classes found in the framework – for lack of a better word – are meant to aid in the utilitarian way in which business applications are styled.
2. I dislike inline styles, but do not mind a composition of classes to achieve a certain result. This is a good middle ground between a completely custom rule for the element and inline styles.
3. I reserve the creation of custom styles for the elements that truly are unique in your project. For example I don’t like to reinvent the wheel when doing grid layouts. I have a solid grid system that is tested across browsers.
4. I’ve said this before, but it bears repeating I’m a developer, not a designer. This is a framework that has worked for me in my projects. It is not 100% perfect or bug free. For the 10% outlier, I simply write custom CSS to cover these use cases.
What’s in it?
A browser reset
I believe Eric Meyer’s is the best and longest standing browser reset out there. For you who are not familiar with browser resets, the short of it is, that every browser before they apply your styles, the browser’s default stylesheet gets applied, and it creates the base set of styles for the the page. Trouble is, every browser has a slightly different base style, which makes your design vary from browser to browser based on the inherited base style. To counter this, you can create a reset if you will, which neutralizes all default browser styling and creates a baseline which is the same across all your browsers.
Baseline
Once you have run a browser reset, you have created a consistent baseline accross all browsers by removing all (almost) styles, but now you don’t have any defaults. The baseline serves the purpose of creating a default look for the common elements like heading tags, paragraphs, etc.
Fix for IE box model. The clearfix hack
The clearfix hack is used in order to clear floated elements. While this should be a straightforward procedure, IE makes it very challenging, as is with most other issues in IE, it implements the html spec slightly different from other browsers. The included clearfix hack, fixes all these inconsistencies and renders correctly across IE5.5+ as well as Firefox, Chrome, Safari, Opera. See this article for a clear description of the problem and it’s solutions.
The short of it is, if you have this markup, if you are floating elements inside a container, all you have to do is apply the clearfix class to the parent container and all floated children will behave correctly. for example:
1: <div class="clearfix">
2: <div class="fl">fl = Float left</div>
3: <div class="fr">fr = Float right</div>
4: </div>
Type
As part of the baseline, it creates a base type setting which is as follows:
1: {
2: font-family:Segoe UI,Arial,Verdana,Helvetica,sans-serif;
3: font-size: 12px;
4: text-align:left;
5: }
This works well in most browsers, and while I understand the shortcomings of pixel based font sizes, it just works, like I’ve said before for the cases where this does not fit, then use a custom classes, or change the default.
There is also standard sizes represented by classes. Theses classes correctly fix the problem of being overridden by element direct styling typical in a, input, td, select, and textarea tags. When you assign one of these classes to any element, it insures that it takes precedence.
s = small (13px)
xs = extra small (10px)
xxs = extra extra small (9px)
m = medium (16px)
l = large (19px)
xl =extra large (24px)
xxl = extra extra large (32px)
Floats
To float elements left or right simply apply these classes to the element. Remember to wrap them with a container that has the clearfix class applied as in the example above.
fl = float left
fr = float right
Widths, Heights, Padding and Margins
I know that some of you will balk at the idea of classes with preset sizes, but before you decide to start hurling stones, remember what I said before, every class that is there, is there because I use it often and find it to simplify and speed up my development. Like I’ve said this is a good middle ground before custom css rules for everything, and inline styles (which are evil).
w{number} = Sets the width of the element to the {number} of pixels specified. for example w25, sets the width of the element to 25px. Numbers from 1-10 are in 1 pixel increments, 10-200 are in 5 pixel increments and 200-600 are in 25 pixel increments and 600-980 are in 10 pixel increments. With the exception of the standard ad sizes as found here
wp{number} = Sets the width of the element in percentages of it’s parent’s size. 1-10 and 95-100 are in 1% increments, the reset are in 5% point increments.
h{number} = Sets the height of the element in pixels. Numbers from 1-31 are in 1 pixel increments, from 30-250 are in 5 pixel increments, 250-600 are in 10 pixel increments
m{number} = Sets the margin for an element to the specified number. Numbers from 1-10 are in 1 pixel increments, 10-50 are in 5 pixel increments.
mt{number} , mr{number}, mb{number}, ml{number} = Sets the margin-[top, right, bottom, left] correspondingly. Numbers from 1-10 are in 1 pixel increments, 10-50 are in 5 pixel increments.
p{number} = Sets the padding for an element to the specified number. Numbers from 1-10 are in 1 pixel increments, 10-50 are in 5 pixel increments.
pt{number} , pr{number}, pb{number}, pl{number} = Sets the padding-[top, right, bottom, left] correspondingly. Numbers from 1-10 are in 1 pixel increments, 10-50 are in 5 pixel increments.
Colors and Backgrounds
These are particularly useful in application development, as you often want to change the color or background to a preset set of colors, but it is not imperative that you be extremely precise with the color as you would with the palette of a hand crafted site. In these cases having some preset colors greatly improves the consistency and speed with which you can achieve relevance through design in your applications.
bg{color} = stands for background-color and then the color specified. colors included are: white, black, light, dark, hl (which means highlight, sets the background to a light yellow), the colors are as described by their name.
black, white, red, xdard, dark, light, xlight = Sets the color css attribute of elements (including overriding the anchor tag color if applied to an anchor) to the appropriate color.
Display and Position
hide = sets the display property of the element to none
block = sets the display property of the element to block
inline = sets the display property of the element to inline
inlineb = sets the display property of the element to inline-block
prel = sets the position to relative
pabs = sets the position to absolute
pfixed = sets the position to fixed
pstatic = sets the position to static
Text alignment
tr = text-align: right
tl = text-align: left
tc = text-align: center
tj = text-align: justify
tvt = vertical-align: top
tvc = vertical-align: middle
tvb = vertical-align: bottom
Grid
The grid is loosely based on the 960 fluid grid. It basically implements a 16 column grid that uses percentages. I use percentages because it is particularly useful to include in other containers that might not be necessarily the whole page. For instance you can apply the grid to just a div element within your page, and it will divide that element into 16 equal columns using percentages. Particularly useful when using the the system for styling a module.
Best to way to show it is to show you some code:
1: <!--You apply the grid to an element by adding the g16 class to it-->
2: <div class="g16">
3: <div class="gc5 firstc">
4: This takes 5 of the sixteen columns and marks it as the first column with the firstc class,
5: the firstc class kills the left gutter space for this column
6: </div>
7: <div class="gc3">
8: Yet another column taking another 3/16 of the space
9: </div>
10: <div class="gc8 lastc">
11: Another column taking the ramining 8/16 space in the grid.
12: lastc class marks the column as the last in the grid and kills the right gutter
13: </div>
14:
15:
16: <!-- This clears the previous columns, but you only have to
17: use when the next column is not a full column -->
18: <div class="clear"></div>
19:
20: <div class="gc16">
21: A full column does not have to be cleared or marked with the lastc and firstc classes
22: </div>
23:
24: </div>
The grid is pretty simple really, just a way to evenly divide any container element into 16 equal columns.
Miscellaneous Classes
pointer = sets the cursor to be the pointer when the mouse is over this element
cnomal = sets the mouse cursor to the normal sate
b = set the font-weight to bold
fieldlabel = sets an element ot display lock and ad bottom padding of 3 pixels this is used on <label> elements that pertain to input controls
nowrap =adds text-whitespace: nowrap
strike = adds text-decoration: line-through
cmd = used on anchor tag to make them small red and bold as it it were a command rather than just a simple link. { font-size: 10px; font-weight:bold; color:red; }
hlist = makes an unordered list’s <ul> elements display inline and horizotally, useful when creating menu and other horizontal use of <ul>
tablemin = turns a properly formatted table (one that uses the <thead> <th> and <tbody> elements) into an instance nicely displayed one by adding formatting to it in a very simplistic style
error = When applied to an element it turns it’s color red, and sets the font and font size to display as an error. Useful in applications when you want to visibly adorn an invalid input.
What about partial page styling (CMS mode)
I also created an alternative CSS stylesheet, BigfootWeb_Module.css, which would be referenced instead of BigfootWeb.css. It contains all of the same classes and styles, except they are only applied to the element in your page named bfbox.
Also by default the browser reset is not applied unless you specifically also add the reset class to the bfbox element. That’s it, very simply really. A quick example:
1: <div>
2: This some other page content, not affected by bigfootCSS.
3: bigfootCSS rules do not apply here.
4: </div>
5:
6: <div id="bfbox" class="reset">
7: All elements inside this box are now under the bigfootCSS reset, and baseline
8: as well as all css classes and rules would apply to all children of this element
9: </div>
10:
11: <div>
12: Back to the page, again not affected by bigfootCSS.
13: </div>
Please not that if you don’t want the browser reset portion to apply to your bfbox container, simply don’t apply the reset class. This will allow you to inherit all the CSS rules from your skin / page while still being able to take advantage of most of the classes in the framework.
Putting it all together
You can now put these classes together to create a very fast and clean layout for your page without having to create custom CSS rules for everything.
For a more complete example please visit http://cdn.mitmar.com/bigfootcss/Main.html
Cheers!
Mitch