CSS Master

(Primo) #1
display: inline-block;
font-size: 16 px;
}

It’salsopossibletocreateamixinrulesetwithoutitbeingincludedintheoutput.
Todoso,addparenthesestotheselector.Inthisexample,.dibwouldbecome
.dib()instead.


Mixinscanalsoacceptparameters,makingthemperfectformanagingvendorpre-
fixes.Let’slookatanexampleusingtheCSS3transitionproperty.First,we’ll
defineourmixin:


.transition(@props) {
-webkit-transition: @props;
transition: @props;
}

Nowwecanuseitwithinourrulesets:


.fade {
.transition(opacity 100ms linear);
}

.open {
.transition(height 500ms linear);
}

Whencompiled,Lessreplacesthevalueof@propswiththeargumentpassed,and
outputstheprefixedCSSwe’veprescribed:


.fade {
-webkit-transition: opacity 100ms linear;
-moz-transition: opacity 100ms linear;
transition: opacity 100ms linear;
}

.open {
-webkit-transition: height 500ms linear;

Preprocessors 343

Free download pdf