evolutiondesign's posterous

Bootstrap, from Twitter

How to use it

Use this option to make full use of Bootstrap’s Less variables, mixins, and nesting in CSS via javascript in your browser.

  1. <link rel="stylesheet/less" href="less/bootstrap.less" media="all" />
  2. <script src="js/less-1.0.41.min.js"></script>

Not feeling the .js solution? Try the Less Mac app or use Node.js to compile when you deploy your code.

What’s included

Here are some of the highlights of what’s included in Twitter Bootstrap as part of Bootstrap. Head over to the Bootstrap website or Github project page to download and learn more.

Color variables

Variables in Less are perfect for maintaining and updating your CSS headache free. When you want to change a color value or a frequently used value, update it in one spot and you’re set.

  1. // Links
  2. @linkColor: #8b59c2;
  3. @linkColorHover: darken(@linkColor, 10);
  4.  
  5. // Grays
  6. @black: #000;
  7. @grayDark: lighten(@black, 25%);
  8. @gray: lighten(@black, 50%);
  9. @grayLight: lighten(@black, 70%);
  10. @grayLighter: lighten(@black, 90%);
  11. @white: #fff;
  12.  
  13. // Accent Colors
  14. @blue: #08b5fb;
  15. @green: #46a546;
  16. @red: #9d261d;
  17. @yellow: #ffc40d;
  18. @orange: #f89406;
  19. @pink: #c3325f;
  20. @purple: #7a43b6;
  21.  
  22. // Baseline
  23. @baseline: 20px;

Commenting

Less also provides another style of commenting in addition to CSS’s normal /* ... */ syntax.

  1. // This is a comment
  2. /* This is also a comment */

Mixins up the wazoo

Mixins are basically includes or partials for CSS, allowing you to combine a block of code into one. They’re great for vendor prefixed properties like box-shadow, cross-browser gradients, font stacks, and more. Below is a sample of the mixins that are included with Bootstrap.

Font stacks

  1. #font {
  2. .shorthand(@weight: normal, @size: 14px, @lineHeight: 20px) {
  3. font-size: @size;
  4. font-weight: @weight;
  5. line-height: @lineHeight;
  6. }
  7. .sans-serif(@weight: normal, @size: 14px, @lineHeight: 20px) {
  8. font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  9. font-size: @size;
  10. font-weight: @weight;
  11. line-height: @lineHeight;
  12. }
  13. .serif(@weight: normal, @size: 14px, @lineHeight: 20px) {
  14. font-family: "Georgia", Times New Roman, Times, sans-serif;
  15. font-size: @size;
  16. font-weight: @weight;
  17. line-height: @lineHeight;
  18. }
  19. .monospace(@weight: normal, @size: 12px, @lineHeight: 20px) {
  20. font-family: "Monaco", Courier New, monospace;
  21. font-size: @size;
  22. font-weight: @weight;
  23. line-height: @lineHeight;
  24. }
  25. }

Gradients

  1. #gradient {
  2. .horizontal (@startColor: #555, @endColor: #333) {
  3. background-color: @endColor;
  4. background-repeat: repeat-x;
  5. background-image: -khtml-gradient(linear, left top, right top, from(@startColor), to(@endColor)); // Konqueror
  6. background-image: -moz-linear-gradient(left, @startColor, @endColor); // FF 3.6+
  7. background-image: -ms-linear-gradient(left, @startColor, @endColor); // IE10
  8. background-image: -webkit-gradient(linear, left top, right top, color-stop(0%, @startColor), color-stop(100%, @endColor)); // Safari 4+, Chrome 2+
  9. background-image: -webkit-linear-gradient(left, @startColor, @endColor); // Safari 5.1+, Chrome 10+
  10. background-image: -o-linear-gradient(left, @startColor, @endColor); // Opera 11.10
  11. -ms-filter: %("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=1)",@startColor,@endColor); // IE8+
  12. filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=1)",@startColor,@endColor)); // IE6 & IE7
  13. background-image: linear-gradient(left, @startColor, @endColor); // Le standard
  14. }
  15. .vertical (@startColor: #555, @endColor: #333) {
  16. background-color: @endColor;
  17. background-repeat: repeat-x;
  18. background-image: -khtml-gradient(linear, left top, left bottom, from(@startColor), to(@endColor)); // Konqueror
  19. background-image: -moz-linear-gradient(@startColor, @endColor); // FF 3.6+
  20. background-image: -ms-linear-gradient(@startColor, @endColor); // IE10
  21. background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, @startColor), color-stop(100%, @endColor)); // Safari 4+, Chrome 2+
  22. background-image: -webkit-linear-gradient(@startColor, @endColor); // Safari 5.1+, Chrome 10+
  23. background-image: -o-linear-gradient(@startColor, @endColor); // Opera 11.10
  24. -ms-filter: %("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",@startColor,@endColor); // IE8+
  25. filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",@startColor,@endColor)); // IE6 & IE7
  26. background-image: linear-gradient(@startColor, @endColor); // The standard
  27. }
  28. .directional (@startColor: #555, @endColor: #333, @deg: 45deg) {
  29. ...
  30. }
  31. .vertical-three-colors(@startColor: #00b3ee, @midColor: #7a43b6, @colorStop: 0.5, @endColor: #c3325f) {
  32. ...
  33. }
  34. }

Operations and grid system

Get fancy and perform some math to generate flexible and powerful mixins like the one below.

  1. // Griditude
  2. @gridColumns: 16;
  3. @gridColumnWidth: 40px;
  4. @gridGutterWidth: 20px;
  5.  
  6. // Grid System
  7. .container {
  8. width: @siteWidth;
  9. margin: 0 auto;
  10. .clearfix();
  11. }
  12. .columns(@columnSpan: 1) {
  13. display: inline;
  14. float: left;
  15. width: (@gridColumnWidth * @columnSpan) + (@gridGutterWidth * (@columnSpan - 1));
  16. margin-left: @gridGutterWidth;
  17. &:first-child {
  18. margin-left: 0;
  19. }
  20. }
  21. .offset(@columnOffset: 1) {
  22. margin-left: (@gridColumnWidth * @columnOffset) + (@gridGutterWidth * (@columnOffset - 1)) !important;
  23. }

How to leverage this into a theme? Ideas flowing...

Bootstrap, from Twitter

How to use it

Use this option to make full use of Bootstrap’s Less variables, mixins, and nesting in CSS via javascript in your browser.

  1. <link rel="stylesheet/less" href="less/bootstrap.less" media="all" />
  2. <script src="js/less-1.0.41.min.js"></script>

Not feeling the .js solution? Try the Less Mac app or use Node.js to compile when you deploy your code.

What’s included

Here are some of the highlights of what’s included in Twitter Bootstrap as part of Bootstrap. Head over to the Bootstrap website or Github project page to download and learn more.

Color variables

Variables in Less are perfect for maintaining and updating your CSS headache free. When you want to change a color value or a frequently used value, update it in one spot and you’re set.

  1. // Links
  2. @linkColor: #8b59c2;
  3. @linkColorHover: darken(@linkColor, 10);
  4.  
  5. // Grays
  6. @black: #000;
  7. @grayDark: lighten(@black, 25%);
  8. @gray: lighten(@black, 50%);
  9. @grayLight: lighten(@black, 70%);
  10. @grayLighter: lighten(@black, 90%);
  11. @white: #fff;
  12.  
  13. // Accent Colors
  14. @blue: #08b5fb;
  15. @green: #46a546;
  16. @red: #9d261d;
  17. @yellow: #ffc40d;
  18. @orange: #f89406;
  19. @pink: #c3325f;
  20. @purple: #7a43b6;
  21.  
  22. // Baseline
  23. @baseline: 20px;

Commenting

Less also provides another style of commenting in addition to CSS’s normal /* ... */ syntax.

  1. // This is a comment
  2. /* This is also a comment */

Mixins up the wazoo

Mixins are basically includes or partials for CSS, allowing you to combine a block of code into one. They’re great for vendor prefixed properties like box-shadow, cross-browser gradients, font stacks, and more. Below is a sample of the mixins that are included with Bootstrap.

Font stacks

  1. #font {
  2. .shorthand(@weight: normal, @size: 14px, @lineHeight: 20px) {
  3. font-size: @size;
  4. font-weight: @weight;
  5. line-height: @lineHeight;
  6. }
  7. .sans-serif(@weight: normal, @size: 14px, @lineHeight: 20px) {
  8. font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  9. font-size: @size;
  10. font-weight: @weight;
  11. line-height: @lineHeight;
  12. }
  13. .serif(@weight: normal, @size: 14px, @lineHeight: 20px) {
  14. font-family: "Georgia", Times New Roman, Times, sans-serif;
  15. font-size: @size;
  16. font-weight: @weight;
  17. line-height: @lineHeight;
  18. }
  19. .monospace(@weight: normal, @size: 12px, @lineHeight: 20px) {
  20. font-family: "Monaco", Courier New, monospace;
  21. font-size: @size;
  22. font-weight: @weight;
  23. line-height: @lineHeight;
  24. }
  25. }

Gradients

  1. #gradient {
  2. .horizontal (@startColor: #555, @endColor: #333) {
  3. background-color: @endColor;
  4. background-repeat: repeat-x;
  5. background-image: -khtml-gradient(linear, left top, right top, from(@startColor), to(@endColor)); // Konqueror
  6. background-image: -moz-linear-gradient(left, @startColor, @endColor); // FF 3.6+
  7. background-image: -ms-linear-gradient(left, @startColor, @endColor); // IE10
  8. background-image: -webkit-gradient(linear, left top, right top, color-stop(0%, @startColor), color-stop(100%, @endColor)); // Safari 4+, Chrome 2+
  9. background-image: -webkit-linear-gradient(left, @startColor, @endColor); // Safari 5.1+, Chrome 10+
  10. background-image: -o-linear-gradient(left, @startColor, @endColor); // Opera 11.10
  11. -ms-filter: %("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=1)",@startColor,@endColor); // IE8+
  12. filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=1)",@startColor,@endColor)); // IE6 & IE7
  13. background-image: linear-gradient(left, @startColor, @endColor); // Le standard
  14. }
  15. .vertical (@startColor: #555, @endColor: #333) {
  16. background-color: @endColor;
  17. background-repeat: repeat-x;
  18. background-image: -khtml-gradient(linear, left top, left bottom, from(@startColor), to(@endColor)); // Konqueror
  19. background-image: -moz-linear-gradient(@startColor, @endColor); // FF 3.6+
  20. background-image: -ms-linear-gradient(@startColor, @endColor); // IE10
  21. background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, @startColor), color-stop(100%, @endColor)); // Safari 4+, Chrome 2+
  22. background-image: -webkit-linear-gradient(@startColor, @endColor); // Safari 5.1+, Chrome 10+
  23. background-image: -o-linear-gradient(@startColor, @endColor); // Opera 11.10
  24. -ms-filter: %("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",@startColor,@endColor); // IE8+
  25. filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",@startColor,@endColor)); // IE6 & IE7
  26. background-image: linear-gradient(@startColor, @endColor); // The standard
  27. }
  28. .directional (@startColor: #555, @endColor: #333, @deg: 45deg) {
  29. ...
  30. }
  31. .vertical-three-colors(@startColor: #00b3ee, @midColor: #7a43b6, @colorStop: 0.5, @endColor: #c3325f) {
  32. ...
  33. }
  34. }

Operations and grid system

Get fancy and perform some math to generate flexible and powerful mixins like the one below.

  1. // Griditude
  2. @gridColumns: 16;
  3. @gridColumnWidth: 40px;
  4. @gridGutterWidth: 20px;
  5.  
  6. // Grid System
  7. .container {
  8. width: @siteWidth;
  9. margin: 0 auto;
  10. .clearfix();
  11. }
  12. .columns(@columnSpan: 1) {
  13. display: inline;
  14. float: left;
  15. width: (@gridColumnWidth * @columnSpan) + (@gridGutterWidth * (@columnSpan - 1));
  16. margin-left: @gridGutterWidth;
  17. &:first-child {
  18. margin-left: 0;
  19. }
  20. }
  21. .offset(@columnOffset: 1) {
  22. margin-left: (@gridColumnWidth * @columnOffset) + (@gridGutterWidth * (@columnOffset - 1)) !important;
  23. }

How to leverage this into a theme? Ideas flowwing...

Centering (horizontally and vertically) an image in a box

Centering (horizontally and vertically) an image in a box

Nice solution from an article on this problem by Steve Clay.

The problem

We want to center an image inside a container, bigger than the image and with assigned dimensions. The image is not a background one, it’s a true <img> element.

Any image has well defined dimensions, so the easiest and most reliable way to solve the problem is:

  • make the image display:block
  • assign to the image the needed left and top margins to get it centered in the container. Each of this margin value is obviously half the difference between a dimension of the container and that of the image.

For example if you have images of two different sizes, like in a photo gallery with “landscape” and “portrait” images, to be centered in fixed size containers, then assigning to each <img> one of two classes (with different margins) will solve the problem.

But there are cases when one does not want to use the previous method. For example when many images, all with different dimensions are involved and it is not practical to assign different margins to each of them, or when the dimensions of the container and those of the image are not expressed in the same units (px, em, %, …) hence the difference cannot be computed. It’s useful to have a different solution, independent on the image’s size.

A solution

The horizontal centering is not difficult. If the image is left with its default inline display, then text-align: center is the obvious solution, working well in all browsers.display: block, then the usual method for horizontal centering of blocks can be applied, consisting in margin-left:auto; margin-right:auto (plus text-align: center on the container for IE5.x/Win.) -->

For the vertical centering the best solution, working in modern browsers, is to assign display: table-cell; vertical-align: middle to the container. This works in Gecko based browsers, Opera 6+, Safari, IE8. It leaves IE7 and lower (both Windows and Mac) out.

For IE7- the idea is to create a sort of line-box having as height the height of the container, and the using again vertical-align: middle. The line-height property cannot be used to achieve this, since it doesn’t work correctly in IE7-/Win in presence of images. Also the use of a big font-size (without specifying line-height) is problematic, because the height of the generated box is slightly bigger than the font-size. And IE5/Mac (differently from IE/Win) is able to resize (according to user choice) line-height and font-size expressed in pixels, so it would have problems with this approach, unless the height of the container is expressed in em. Note: this same argument precludes the general use of such vertical centering method, based on line-height, in Gecko based and Safari browsers.

Fortunately IE7- has (partial) support for display: inline-block. If an empty inline-block element (for example a span) is added inside the container and it is assigned height: 100%; vertical-align: middle then it allows to precisely get what we want: a line box with the desired height. In other words, the inline-block element respects an assigned height (equal to the container’s one) and props the line open, so that vertical-align: middle (both on the extra element and the image) gives the desired vertical centering.

Some details:

  • The extra, empty inline-block element may have zero width in IE7-/Win, but it must have at least width: 1px in IE/Mac, otherwise it has no effect (this sometimes offsets the horizontal centering by 1px. It could be counteracted with a -1px margin, but the problem is barely visible.)
  • In IE5/Mac the vertical centering is some pixels off. The use of a small font-size or line-height on the container seems beneficial, not clear why (IE5/Mac is a bit incoherent here, especially when playing with its font size settings.)

A combined solution, using display: table-cell and the extra span with display: inline-block, works in Gecko based browsers, Opera 6+. Safari, IE5+/Win, IE5/Mac.

A variation of this technique can be used to vertically center a block element (even with unknown height) inside another one (with known height) which is a more interesting problem.

The code

Putting all together, and naming “wraptocenter” the class of the container, that’s the relevant CSS. Code for IE/Mac is wrapped in a suitable filter. Code for IE7-/Win is put in conditional comments.

<style type="text/css">.wraptocenter {    display: table-cell;    text-align: center;    vertical-align: middle;    width: ...;    height: ...;}.wraptocenter * {    vertical-align: middle;}/*\*//*/.wraptocenter {    display: block;}.wraptocenter span {    display: inline-block;    height: 100%;    width: 1px;}/**/</style><!--[if lt IE 8]><style>.wraptocenter span {    display: inline-block;    height: 100%;}</style><![endif]-->

And that’s the relevant HTML

<div class="wraptocenter"><span></span><img src="..." alt="..."></div>

Other, slightly more complex, examples: images in floated containers, an image gallery with captions.

 

An article on this problem by Steve Clay.

Many thanks to Ingo Chao, for his help and comments.

CSS tests home

 

Shopify, a Start-Up, Starts Its Own Business Competition - You’re the Boss Blog - NYTimes.com

Shopify, a Start-Up, Starts Its Own Business Competition

  by Daniel Weinand Tobias Lütke, founder of Shopify
The Prize

It is routine, of course, for start-ups to participate in business plan competitions and related events. It is virtually unheard of, however, that a start-up would hold its own competition to foster start-ups — especially one offering a first-place prize of $100,000. But that is precisely what a start-up called Shopify is doing.

Founded by Tobias Lütke, Shopify is a software-as-a-service company that provides affordable tools to run a Web store. It has 20 full-time employees with headquarters in Ottawa. The Shopify application began in beta in 2006, and the company generated its first full year of revenue in 2007. Last year, it says, its revenue exceeded $2 million.

The business competition — Build a Business — started taking entries in January, and is open to any new, Shopify-enabled Web store based (in participating states) in the United States. The Shopify subscriber with the highest revenue in its best two months from the period between January and June will win the $100,000 prize. Prizes of $5,000 each will go to the overall runner-up and to top stores selling apparel, digital goods and electronics. Entries are permitted until April 30.  

.............Summary Please see the original article on the NYT boss.blogs.nytimes.com

See The Prize’s guide to coming business plan competitions. And here’s how to win a competition.

 

Code Style: Font stack builder: Hoefler Text, Times, Georgia, Bitstream Vera Serif

Font stack builder

Use the Code Style font stack builder to create robust CSS font-family declarations. The font stack builder shows the probability that your preferred fonts are displayed on Windows, Mac and Linux Web browsers.

Quick start: Build better CSS font stacks

Bookmark: This font stack URL is permanent, you can link to it.

Comment: Send your font stack builder feedback.

Improve your font stack

Add more font families using the selectors below. Click the up and down buttons to re-order the stack. Click the cross button to remove a font from the stack.

Font stack with CSS display probabilities per font, per platform Font name Windows Mac Linux   Hoefler Text 1.16% 88.70% 0.00%
Times 4.65% 10.87% 24.69%
Georgia 92.83% 0.40% 45.33%
Bitstream Vera Serif 0.29% 0.00% 22.58%
serif 1.07% 0.02% 7.40% What's this?

Get the CSS declaration for this font stack.

Styled with your font stack

This text sample has an inline style rule that uses your font stack, including the generic font family.

What do the font stack percentages mean?

With CSS, if a single person happens to have the first named font installed, the chance that any other font is displayed on their screen will be zero. When you apply this principle to a large number of people like Web users, it is possible to calculate an overall probability that each font in a font stack will be displayed because some people will not have the first font, second or third fallback font. These percentage probability figures therefore equate to the proportion of people whose browsers will display each font in the stack, depending on which operating system they use.

What are the generic font family figures?

A CSS font stack is a priority list where the first matched font is selected, so the overall probability that fonts at the top of the stack are installed and displayed affects the proportion of people whose browsers will display those further down the stack. If the sum probability for all the named fonts is less than 100%, what remains is the probability that an un-specified generic font family will be displayed. In other words, a proportion of users may not match any named fonts and their font selection will fall through to the generic font family.

CSS font family declaration

Click and drag over this font family declaration to select, copy and paste into your style sheet.

font-family: "Hoefler Text",             Times,             Georgia,             "Bitstream Vera Serif",             serif;

Font stack probabilities are based on data from the Code Style font survey for Windows, Mac and Linux operating systems. Special terms apply to the Nuvola icon theme.

 

How to make durable plant markers

I have just planted our garden for the summer (stage 2) and thought this may come in handy for those like minded fellow gardeners.

Free Vectors - 28 Halftone Vectors (Clean & Grunge Versions) | Think Design

These free halftone vectors just came in super handy on a project. So thanks for sharing Nick! Check this blog often for excellent articles and freebies.

Sprouts and microgreens: edible houseplants

Microgreens and sprouts, those immature vegetables short on size but large on taste, are making their way from trendy restaurants and stylish markets into family kitchens.

Fresh and so easy to grow too. I just finished my potato tower today and can't wait to start picking my fresh bakers in the fall. This is a nice way to get some quick instant gratification on my green thumb.

65 Very Creative and Funny Photoshopped Images | 1stwebdesigner - Love In Design

Some very creative Photoshoped images. If you look through these you will find a few common themes throughout. My favorites on these are the ones that incorporate natural textures in soft subtle overlays.

Artist creates invisible car - Telegraph

Pretty darn cool if you ask me. Great creative marketing of herself. She did this in only three weeks!

12
To Posterous, Love Metalab