To use lesshat, you need node/npm installed then run npm install lesshat --save to install and save lesshat into your package.json. From here, you just need to reference the node_modules/lesshat/lesshat.less file within any of your project less files. You can also use the prefixed version available at node_module/lesshat/lesshat-prefixed.less if you're worried about mixin name conflicts with other library.
You can also use the command line to install it by running bower install lesshat=https://registry.npmjs.org/lesshat/-/lesshat-4.0.1.tgz --save.
After that, you can reference the less file directly the same way as the npm version with a slight path difference. The only downside is that bower will not update automatically because it doesn't support semantic versioning with files.
You should really consider using npm instead of bower.
Introduction
Why lesshat? In August 2012, while we were developing and extending CSS Hat for LESS we needed universal mixins. Unfortunately, none of available were good enough that would satisfy our needs and that’s why we created new custom ones on our own, which have become the most popular mixin library for the whole LESS CSS.
Meet the best mixins library in the world.
Features
No restrictions – If it's possible in CSS, it must be possible to be done with a mixin. Unlimited number of anything, shadows, gradients, gradient swatches.
Standard naming convention – In lesshat, mixins have names like all CSS3 properties. No .rounded or .shadow. It's stupid.
Cross-browser – lesshat takes care of exporting CSS for all available browsers.
Bootstrap friendly – You can now use prefixed lesshat version and gaily work with Bootstrap. Yeah it's that easy.
Keyframes – Although it's tricky as hell, but yeah lesshat has mixin for .keyframes
Blank state ready – If you call mixin without any arguments, lesshat does not pollute your CSS with empty properties. Instead lesshat generates nothing.
Workflow – No more one line editing! We created developer friendly worklow for editing and creating mixins. You can test mixins with MOCHA, generate new mixin with GRUNT. Find out more about the workflow in contribution section.
.keyframes(~''); .calc(~''); .selection(~''); // in some cases you have to interpolate border-radius or LESS CSS begins to play on calculator .border-radius(~'20px / 40px');
Contribute:
Fork this repo
run npm install
If you create new mixin, please add tests and documentation on how to use it
Always test your changes and make sure that the documentation is being added to the README.md by running grunt
Finally, commit your changes and create a pull request
The CSS align-content property aligns a flex container's lines within the flex container when there is an extra space on the cross-axis. This property has no effect on the single line flexible boxes.
The align-self CSS property aligns flex items of the current flex line overriding the align-items value. If any of the flex item's cross-axis margin is set to auto, then align-self is ignored.
div { .animation(nameAnimation 2s linear alternate);}// Resultdiv { -webkit-animation: nameAnimation 2s linear alternate; -moz-animation: nameAnimation 2s linear alternate; -o-animation: nameAnimation 2s linear alternate; animation: nameAnimation 2s linear alternate;}
• animation-delay
Summary:
Defines a length of time to elapse before an animation starts, allowing an animation to begin execution some time after it is applied.
The animation-name CSS property specifies a list of animations that should be applied to the selected element. Each name indicates a @keyframes at-rule that defines the property values for the animation sequence.
The animation-play-state CSS property determines whether an animation is running or paused. You can query this property's value to determine whether or not the animation is currently running; in addition, you can set its value to pause and resume playback of an animation.
The animation-timing-function CSS property determines whether an animation is running or paused. You can query this property's value to determine whether or not the animation is currently running; in addition, you can set its value to pause and resume playback of an animation.
The CSS backface-visibility property determines whether or not the back face of the element is visible when facing the user. The back face of an element always is a transparent background, letting, when visible, a mirror image of the front face be displayed.
With the background-image you can create prefixed linear or radial gradients. The CSS (linear|radial)-gradient() function creates an <image> which represents a linear|radial gradient of colors. The result of this function is an object of the CSS <gradient> data type. Like any other gradient, a CSS linear gradient is not a CSS <color> but an image with no intrinsic dimensions; that is, it has neither natural or preferred size, nor ratio. Its concrete size will match the one of the element it applies to.
The background-image mixin is the most robust mixin of all.
It generates SVG for Internet Explorer 9, old webkit, moz and opera syntax.
Always use W3C syntax for the mixin. It can recalculate angle for older syntax, transform to top to bottom syntax and it can omit SVG syntax if it's impossible to express SVG e.g. when you call mixin with 55deg.
If you call mixin without arguments, LESS Hat does not generate anything.
Great online gradient generator.
The background-origin CSS property determines the background positioning area, that is the position of the origin of an image specified using the background-image CSS property.
div { .background-origin(content-box); } // Result div { -webkit-background-origin: content-box; -moz-background-origin: content-box; background-origin: content-box; }
• background-size
Summary:
The background-size CSS property specifies the size of the background images. The size of the image can be fully constrained or only partially in order to preserve its intrinsic ratio.
Applies a Gaussian blur to the input image. The value of ‘radius’ defines the value of the standard deviation to the Gaussian function, or how many pixels on the screen blend into each other, so a larger value will create more blur. If no parameter is provided, then a value 0 is used. The parameter is specified as a CSS length, but does not accept percentage values.
The border-bottom-left-radius CSS property sets the rounding of the bottom-left corner of the element. The rounding can be a circle or an ellipse, or if one of the value is 0 no rounding is done and the corner is square.
If you omit units, border-bottom-left-radius adds px automatically.
If you want to use syntax like 10px \ 5px, you have to interpolate argument ~'' or LESS CSS divides it (yeah awesome feature!).
Also LESS Hat adds background-clip: padding-box, because it fixes problem with older Safari. Here is some resource.
The border-bottom-right-radius CSS property sets the rounding of the bottom-left corner of the element. The rounding can be a circle or an ellipse, or if one of the value is 0 no rounding is done and the corner is square.
If you omit units, border-bottom-right-radius adds px automatically.
If you want to use syntax like 10px \ 5px, you have to interpolate argument ~'' or LESS CSS divides it (yeah awesome feature!).
Also LESS Hat adds background-clip: padding-box, because it fixes problem with older Safari. Here is some resource.
Example:
div { .border-bottom-right-radius(10px); } // Result div { -webkit-border-bottom-right-radius: 10px; -moz-border-radius-bottomright: 10px; border-bottom-right-radius: 10px; }
• border-image
Summary:
The border-image CSS property allows drawing an image on the borders of elements. This makes drawing complex looking widgets much simpler than it has been and removes the need for nine boxes in some cases.
The border-radius CSS property allows Web authors to define how rounded border corners are. The curve of each corner is defined using one or two radii, defining its shape: circle or ellipse.
If you omit units, border-radius adds px automatically.
If you want to use syntax like 10px \ 5px, you have to interpolate argument ~'' or LESS CSS divides it (yeah awesome feature!).
Also LESS Hat adds background-clip: padding-box, because it fixes problem with older Safari. Here is some resource.
The border-top-left-radius CSS property sets the rounding of the top-left corner of the element. The rounding can be a circle or an ellipse, or if one of the value is 0 no rounding is done and the corner is square.
If you omit units, border-top-left-radius adds px automatically.
If you want to use syntax like 10px \ 5px, you have to interpolate argument ~'' or LESS CSS divides it (yeah awesome feature!).
Also LESS Hat adds background-clip: padding-box, because it fixes problem with older Safari. Here is some resource.
The border-top-right-radius CSS property sets the rounding of the top-right corner of the element. The rounding can be a circle or an ellipse, or if one of the value is 0 no rounding is done and the corner is square.
If you omit units, border-top-right-radius adds px automatically.
If you want to use syntax like 10px \ 5px, you have to interpolate argument ~'' or LESS CSS divides it (yeah awesome feature!).
Also LESS Hat adds background-clip: padding-box, because it fixes problem with older Safari. Here is some resource.
The box-shadow CSS property describes one or more shadow effects as a comma-separated list. It allows casting a drop shadow from the frame of almost any element. If a border-radius is specified on the element with a box shadow, the box shadow takes on the same rounded corners. The z-ordering of multiple box shadows is the same as multiple text shadows (the first specified shadow is on top).
The box-sizing CSS property is used to alter the default CSS box model used to calculate widths and heights of elements. It is possible to use this property to emulate the behavior of browsers that do not correctly support the CSS box model specification.
Applies a linear multiplier to input image, making it appear more or less bright. A value of 0% will create an image that is completely black. A value of 100% leaves the input unchanged. Other values are linear multipliers on the effect. Values of an amount over 100% are allowed, providing brighter results. If the ‘amount’ parameter is missing, a value of 100% is used.
The calc() CSS function can be used anywhere a <length>, <frequency>, <angle>, <time>, <number>, or <integer> is required.With calc(), you can perform calculations to determine CSS property values.
THIS MIXIN MUST BE INTERPOLATED ~''
The -lh-property: 0 junk line of code is a neccesary sacrifice due to the hack nature of this set of mixins. (via less-properties)
The column-width CSS property suggests an optimal column width. This is not a absolute value but a mere hint. Browser will adjust the width of the column around that suggested value, allowing to achieve scalable designs that fit different screen size.
Adjusts the contrast of the input. A value of 0% will create an image that is completely black. A value of 100% leaves the input unchanged. Values of amount over 100% are allowed, providing results with less contrast. If the ‘amount’ parameter is missing, a value of 100% is used.
Applies a drop shadow effect to the input image. A drop shadow is effectively a blurred, offset version of the input image's alpha mask drawn in a particular color, composited below the image.
The CSS filter property provides for effects like blurring or color shifting on an element’s rendering before the element is displayed. Filters are commonly used to adjust the rendering of an image, a background, or a border.
The flex CSS property specifies ability of a flex item to alter their dimensions to fill the available space. Flex items can be stretched to use available space proportional to their flex grow factor or their flex shrink factor to prevent overflow.
If you omit units, flex-basis adds px automatically.
Example:
div { .flex-basis(100);}// Resultdiv { -webkit-flex-basis: 100; flex-basis: 100px;}
• flex-direction
Summary:
The CSS flex-direction property specifies how flex items are placed in the flex container defining the main axis and the direction (normal or reversed).
Converts the input image to grayscale. The value of ‘amount’ defines the proportion of the conversion. A value of 100% is completely grayscale. A value of 0% leaves the input unchanged. Values between 0% and 100% are linear multipliers on the effect. If the ‘amount’ parameter is missing, a value of 100% is used.
Applies a hue rotation on the input image. The value of ‘angle’ defines the number of degrees around the color circle the input samples will be adjusted. A value of 0deg leaves the input unchanged. If the ‘angle’ parameter is missing, a value of 0deg is used. Maximum value is 360deg.
Inverts the samples in the input image. The value of ‘amount’ defines the proportion of the conversion. A value of 100% is completely inverted. A value of 0% leaves the input unchanged. Values between 0% and 100% are linear multipliers on the effect. If the ‘amount’ parameter is missing, a value of 100% is used.
The CSS justify-content property defines how a browser distributes available space between and around elements when aligning flex items in the main-axis of the current line.
The @keyframes CSS at-rule lets authors control the intermediate steps in a CSS animation sequence by establishing keyframes (or waypoints) along the animation sequence that must be reached by certain points during the animation.
LESS CSS isn't great for complicated mixin like this one, so it's little bit tricky.
LESS CSS compiler doesn't allow to have properties in the root. It's better to understand the problem on the example.
// There is no selectorcolor: red;SyntaxError: properties must be inside selector blocks, they cannot be in the root. div { color: red; } // This is correct
Therefore LESS Hat generates placeholder selector lesshat-selector { -lh-property: 0; } with unknown property, which browsers ignore and after that, there is actually keyframes syntax.
And also because of bad architecture of LESS CSS language, keyframes definition has to be on single line.
Properties inside <keyframes-definition> are automatically prefixed, if it's needed.
Keyframes mixin supports prefix configuration but it's computationally demanding so it is commented out and all prefixes are rendered. Feel free to uncommented that if you need it.
The perspective CSS property determines the distance between the z=0 plane and the user in order to give to the 3D-positioned element some perspective.
If you omit units, perspective-origin adds % automatically.
Example:
div { .perspective-origin(top left);}// Resultdiv { -moz-perspective-origin: top left; -webkit-perspective-origin: top left; perspective-origin: top left;}
• placeholder
Summary:
Placeholder is the short hint displayed in the input field before the user clicked to it.
Default placeholder text in inputs has a light gray color (so far).
The scale3d() CSS function modifies the size of an element. Because the amount of scaling is defined by a vector, it can resize different dimensions at different scales.
The scaleZ() CSS function modifies the z-coordinate of each element point by a constant facto, except if this scale factor is 1, in which case the function is the identity transform.
The ::selection CSS pseudo-element applies rules to the portion of a document that has been highlighted.
LESS CSS compiler doesn't allow to have properties in the root. It's better to understand the problem on the example.
// There is no selectorcolor: red;SyntaxError: properties must be inside selector blocks, they cannot be in the root. div { color: red; } // This is correct
Therefore LESS Hat generates placeholder selector lesshat-selector { -lh-property: 0; } with un