mixins.less 20.93 KiB
// Mixins.less
// Snippets of reusable CSS to develop faster and keep code readable
// -----------------------------------------------------------------
// UTILITY MIXINS
// --------------------------------------------------
// Clearfix
// --------
// For clearing floats like a boss h5bp.com/q
.clearfix {
  *zoom: 1;
  &:before,
  &:after {
    display: table;
    content: "";
  &:after {
    clear: both;
// Webkit-style focus
// ------------------
.tab-focus() {
  // Default
  outline: thin dotted #333;
  // Webkit
  outline: 5px auto -webkit-focus-ring-color;
  outline-offset: -2px;
// Center-align a block level element
// ----------------------------------
.center-block() {
  display: block;
  margin-left: auto;
  margin-right: auto;
// IE7 inline-block
// ----------------
.ie7-inline-block() {
  *display: inline; /* IE7 inline-block hack */
  *zoom: 1;
// IE7 likes to collapse whitespace on either side of the inline-block elements.
// Ems because we're attempting to match the width of a space character. Left
// version is for form buttons, which typically come after other elements, and
// right version is for icons, which come before. Applying both is ok, but it will
// mean that space between those elements will be .6em (~2 space characters) in IE7,
// instead of the 1 space in other browsers.
.ie7-restore-left-whitespace() {
  *margin-left: .3em;
  &:first-child {
    *margin-left: 0;
.ie7-restore-right-whitespace() {
  *margin-right: .3em;
  &:last-child {
    *margin-left: 0;
7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
// Sizing shortcuts // ------------------------- .size(@height, @width) { width: @width; height: @height; } .square(@size) { .size(@size, @size); } // Placeholder text // ------------------------- .placeholder(@color: @placeholderText) { &:-moz-placeholder { color: @color; } &:-ms-input-placeholder { color: @color; } &::-webkit-input-placeholder { color: @color; } } // Text overflow // ------------------------- // Requires inline-block or block for proper styling .text-overflow() { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } // CSS image replacement // ------------------------- // Source: https://github.com/h5bp/html5-boilerplate/commit/aa0396eae757 .hide-text { font: 0/0 a; color: transparent; text-shadow: none; background-color: transparent; border: 0; } // FONTS // -------------------------------------------------- #font { #family { .serif() { font-family: @serifFontFamily; } .sans-serif() { font-family: @sansFontFamily; } .monospace() { font-family: @monoFontFamily; } } .shorthand(@size: @baseFontSize, @weight: normal, @lineHeight: @baseLineHeight) { font-size: @size; font-weight: @weight; line-height: @lineHeight; } .serif(@size: @baseFontSize, @weight: normal, @lineHeight: @baseLineHeight) { #font > #family > .serif; #font > .shorthand(@size, @weight, @lineHeight); } .sans-serif(@size: @baseFontSize, @weight: normal, @lineHeight: @baseLineHeight) {