Sass and Compass allow for more powerful CSS authoring by adding features like variables, nested rules, mixins and functions. This allows stylesheets to be written in a more modular, maintainable and scalable way. Sass code is compiled to normal CSS for browser rendering. Key features demonstrated include variables for consistent values, nesting to reduce selector complexity, mixins for reusable code snippets, and Compass libraries for common CSS3 features and responsive design.
3. „ CSS zu kompilieren ist total bescheuert,
unnötig und führt zu minderwertigen
Ergebnissen. Wer so etwas nutzt, schlägt auch
wehrlose Omas auf der Straße.
Andreas Dantz, anno 2009
20. SCSS
@import "compass/reset","compass/css3";
@import "layout";
// ============== Vars =====================
$items: 6; // number of items
$arc: 90; // arc of the circle
$angle: $arc/$items; // angle between items
$space:170; // a value in pixel. It's the space between the red circle and the items
$circleCenterX: 30; // the X coord of the red circle center
$circleCenterY: 30; // the Y coord of the red circle center
$disappearDelay: 50;
// Generate items position + keyframes animation
@for $i from 1 through $items {
// I'm not really good in math, so I suppose that they have a better way to calcul coordinates :)
$rad: ( $angle * ($i - 1) + $angle/2 ) * (pi()/180);
$x:round(($circleCenterX + $space) * cos($rad) );
$y:round(-($circleCenterY + $space) * sin($rad) );
// Coords for the rebound during the animation
$xm: round($x * 1.15);
$ym: round($y * 1.15);
$disappearDelay: $disappearDelay * 1.35;
// CSS checkbox + label tricks
#menu:checked ~ .items li:nth-child(#{$i}) {
-webkit-animation-name: "appear-'#{$i}'";
-webkit-animation-duration: 240ms;
-webkit-animation-iteration-count: 1;
-webkit-animation-fill-mode: forwards;
-webkit-animation-delay: (20 * $i)+ms;
}
#menu:not(:checked) ~ .items li:nth-child(#{$i}) {
-webkit-animation-name: "disappear-'#{$i}'";
-webkit-animation-duration: (320 + $disappearDelay)+ms;
-webkit-animation-iteration-count: 1;
-webkit-animation-fill-mode: forwards; h ps://github.com/Victa/path-menu
}
34. Die drei Legitimationen fürs Nesting in SASS
1. Ich möchte mehr Übersicht in meinem
Stylesheet
2. Ich hä e die Selektoren auch manuell in
CSS kombiniert
3. Ich will mir Tipparbeit sparen