Code Monkey home page Code Monkey logo

css-mixins's Introduction

SASS and LESS Mixins

Preset mixins to help speed up web development. Provides cross-browser compatibility with things like:

  • Rounded Corners
  • Opacity
  • Box Shadow
  • Box Shadow (Inset)
  • Gradient (Horizontal)
  • Gradient (Vertical)
  • CSS3 Transition
  • CSS3 Transforms

These will automatically create browser-specific rules to accommodate multiple browsers. For example, the .border-radius(4px) mixin will create:

border-radius			: 4px;
-moz-border-radius		: 4px;
-webkit-border-radius	: 4px;
  • These instructions are for the LESS version. The SASS syntax is a little different, but will have the same results. Check out the SASS Website for their syntax.

Requirements

Installation

  • Include jQuery and LESS
<script src="{path_to_jquery}"></script>
<script src="{path_to_less}"></script>
  • Include mixins.less in the head of your document.
<link rel="stylesheet/less" href="{path_to_mixins}">
  • Alternatively, you can import the mixins.less into the stylesheet you want. At the beginning of your LESS file, use:

@import "mixins";

Usage

Rounded Corners

Set the border radius. Accepts pixels or percentages.

Have a border radius all around: .border-radius(5px);

Create a circle: .border-radius(50%);

Opacity

Set the opacity of any element. This will set the opacity of the element plus its children. For just setting the opacity of a background, look at Background Opacity

.opacity(0.5);

Background Alpha

Creates a transparent background. The contents of the element will stay at normal capacity.

.background-alpha(#000, 0.5);

Box Shadow

Create a box shadow. Accepts 4 options: .box-shadow(@x-size, @y-size, @blur, @color, @spread);

.box-shadow(2px, 2px, 5px, #333, 0px);

Box Shadow (Inset)

Create an inner box shadow. Accepts 4 options: .box-shadow(@x-size, @y-size, @blur, @color, @spread);

.box-shadow-inset(2px, 2px, 5px, #333, 0px);

Gradient (Horizontal)

Create a horizontal gradient. Accepts 2 colors: .gradient-horizontal(#FFF, #E7E7E7);

Gradient (Vertical)

Create a vertical gradient. Accepts 2 colors: .gradient-vertical(#FFF, #E7E7E7);

CSS3 Transition

Applies a CSS3 transition to an element. This will be used to transition CSS effects like :hover.

.transition(@type, @time, @ease); .transition(all, 5s, ease-in-out);

CSS3 Transforms

This includes the simple CSS3 transforms. I'm currently working on a CSS3 animation library to help speed up CSS3 animations. Coming soon...

These transforms include:

  • .transform(@deg);
  • .scale(@multiplier);
  • .rotate(@deg);
  • .skew(@deg, @deg2);

These can be used on :hover actions to create cool effects.

css-mixins's People

Watchers

James Cloos avatar Kyle avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.