SlideShare ist ein Scribd-Unternehmen logo
1 von 26
Downloaden Sie, um offline zu lesen
schöneres
               CSS


mit
Sass & Compass
Sass
Install & Run



$ gem install sass

$ sass --watch style.sass:style.css
$ sass --watch assets/sass:public/css
Basic Syntax
css       scss   sass
Nesting
                                                SASS
 article
     border-top: 1px dashed #eee
     header
         margin-bottom: 15px
     header, section
         color: #eee


                                                 CSS

 article { border-top: 1px dashed #eeeeee; }
 article header { margin-bottom: 15px; }
 article header, article section { color: #eeeeee; }
Parent Selector
                                           SASS
 article
     color: #f00
     &:hover
         color: #00f
     .special &
         h1
             font-size: 2em
                                           CSS

 article { color: red; }
 article:hover { color: blue; }
 .special article h1 { font-size: 2em; }
@media
                                             SASS
 #content
     margin: 0 1.5em
     @media screen and (min-width: 1280px)
         margin: 0 2.5em




                                             CSS

 #content { margin: 0 1.5em; }
 @media screen and (min-width: 1280px) {
     #content { margin: 0 2.5em; }
 }
Variablen
                                           SASS
 $link-color: #e78a15
 $link-hover: #138a1e
 $link-size: 0.8em

 a
     color: $link-color
     font-size: $link-size
     &:hover
         color: $link-hover
                                           CSS

 a { color: #e78a15; font-size: 0.8em; }
 a:hover { color: #138a1e; }
Weiterverwendung mit @extend
                                                SASS
 .button
     background-color: #00f
     color: #fff
     padding: 2em 1.5em

 .button-delete
     @extend .button
     background-color: #f00
                                                 CSS

 .button, .button-delete { background-color: blue;
 color: white; padding: 2em 1.5em; }
 .button-delete { background-color: red; }
Vorlagen mit @mixin
                                                   SASS
 @mixin hover-link
   text-decoration: none
   &:hover
     text-decoration: underline

 article a
   @include hover-link

 .nav a
   color: blue
   @include hover-link                             CSS
 article a { text-decoration: none; }
 article a:hover { text-decoration: underline; }

 .nav a { color: blue; text-decoration: none; }
 .nav a:hover { text-decoration: underline; }
Funktionen mit @mixin
                                      SASS
 @mixin border-radius($amount)
     border-radius: $amount
     -mox-border-radius: $amount
     -webkit-border-radius: $amount

 .alert
     @include border-radius(5px)
                                      CSS

 .alert {
     border-radius: 5px;
     -mox-border-radius: 5px;
     -webkit-border-radius: 5px;
 }
benannte Argumente mit @mixin
                                                  SASS
 @mixin flash-message($bgcolor:red, $hovercolor:blue)
     background-color: $bgcolor
     &:hover
         background-color: $hovercolor

 .alertbox
     @include flash-message($hovercolor: green)
                                                  CSS

 .alertbox { background-color: red; }
 .alertbox:hover { background-color: green; }
Import
 pages/
     _user.sass
 screen.sass
 _variables.sass
 _grid.sass
 _typography.sass
 _phone.sass
                                        SASS
 /* screen.sass */
 @import "variables"
 @import "grid"
 @import "grid", "typography"

 @media screen and (min-width: 480px)
     @import "phone"

 #user
     @import "pages/user"
etwas Mathematik
                                                   SASS
font-size: 18px - 5px
width: 200px * 3


Beispiel:

$layout-space: 10px
$sidebar-width: 250px
$page-width: 960px

#main
    width: $page-width - $sidebar-width - (2 * $layout-space)
                                                   CSS

#main { width: 690px; }
Mathematische Funktionen



abs(-43)            // => 43
floor(3.9)          // => 3
ceil(3.2)           // => 4
round(2.8)          // => 3
percentage(13/25)   // => 52%
Mehr ...

- Bedingungen (@if, @else, @elseif)
- Logische Operatoren (<, >, >=, <=, ==, !=)
- Verknuepfungen (and, or)
- Schleifen (@for, @while, @each)
- Farb-Inspektoren (hue, saturation, lightness, ..)
- Farb-Funktionen (invert, mix, grayscale, darken, ..)
- eigene Funktionen (@function)
...
Compass




@mixin & @function Sammlung
Installation


$ gem install compass

$   compass create my_project
$   cd my_project
$   vim config.rb
$   compass watch

oder

$ sass --compass --watch assets/sass:public/css
Cross Browser CSS3 Mixins

●   Appearance          ●   Filter
●   Background Clip     ●   Font Face
●   Background Origin   ●   Hyphenation
●   Background Size     ●   Images (Gradients)
●   Border Radius       ●   Inline Block
●   Box                 ●   Opacity
●   Box Shadow          ●   CSS Regions
●   Box Sizing          ●   Text Shadow
●   Columns             ●   Transform
                        ●   Transition
Beispiel CSS3 Mixins
                                                  SASS
@import "compass"
.flash-message
  @include background(linear-gradient(#fff, #eee))
  @include border-radius(5px)
                                                     CSS

.flash-message {
    background: -webkit-gradient(linear, 50% 0%, 50% 100%,
    color-stop(0%, #ffffff), color-stop(100%, #eeeeee));
    background: -webkit-linear-gradient(#ffffff, #eeeeee);
    background: -moz-linear-gradient(#ffffff, #eeeeee);
    background: -o-linear-gradient(#ffffff, #eeeeee);
    background: linear-gradient(#ffffff, #eeeeee); -webkit-
    border-radius: 5px; -moz-border-radius: 5px; -ms-
    border-radius: 5px; -o-border-radius: 5px; border-
    radius: 5px;
}
Layout Helper

Grid Background
  Grid als Seitenhintergrund mithilfe CSS3 Gradients

Sticky Footer
  Footer am Seitenende

Stretching
  Dimensionen eines Divs auf das Elternelement
  ausweiten
Utilities


Reset (global, einzelne Resets (Font, body, ..)
Cross Browser Clearfix
Cross Browser Floats
has-layout Hacks
...
Sprites
                                                    SASS

@import "compass"
@import "social/*.png"
@include all-social-sprites
                                                    CSS

.icons-sprite, .icons-facebook, .icons-flickr, .icons-
twitter, .icons-xing { background: url('/images/icons-
s2d05e1e0af.png') no-repeat; }

.icons-facebook { background-position: 0 -48px; }

.icons-flickr { background-position: 0 -16px; }

.icons-twitter { background-position: 0 -32px; }

.icons-xing { background-position: 0 0; }
Informations
● Sass - sass-lang.com
● Sass Ruby on Rails Implementation
  github.com/rails/sass-rails

● Compass - compass-style.org

● Noch mehr Infos
  ○ 35 Great Resources for Compass and Sass
  ○ Sass & Compass: The future of stylesheets now
  ○ css2sass converter
Personal



Stefan Bauckmeier
AKRA GmbH
http://twitter.com/emrox
http://trafex.de
https://www.xing.com/profile/Stefan_Bauckmeier

Weitere ähnliche Inhalte

Was ist angesagt?

SASS is more than LESS
SASS is more than LESSSASS is more than LESS
SASS is more than LESSItai Koren
 
From PSD to WordPress Theme: Bringing designs to life
From PSD to WordPress Theme: Bringing designs to lifeFrom PSD to WordPress Theme: Bringing designs to life
From PSD to WordPress Theme: Bringing designs to lifeDerek Christensen
 
CSS'in Gücü Adına
CSS'in Gücü AdınaCSS'in Gücü Adına
CSS'in Gücü AdınaAdem Ilter
 
Modularization css with sass
Modularization css with sassModularization css with sass
Modularization css with sassHuiyi Yan
 
Front-End Dev Tools
Front-End Dev ToolsFront-End Dev Tools
Front-End Dev ToolsNetguru
 
Doing More With Less
Doing More With LessDoing More With Less
Doing More With LessDavid Engel
 
Sass, Compass and the new tools - Open Web Camp IV
Sass, Compass and the new tools - Open Web Camp IVSass, Compass and the new tools - Open Web Camp IV
Sass, Compass and the new tools - Open Web Camp IVDirk Ginader
 
LESS, the CSS Preprocessor
LESS, the CSS PreprocessorLESS, the CSS Preprocessor
LESS, the CSS PreprocessorAndrea Tarr
 
Using LESS, the CSS Preprocessor: J and Beyond 2013
Using LESS, the CSS Preprocessor: J and Beyond 2013Using LESS, the CSS Preprocessor: J and Beyond 2013
Using LESS, the CSS Preprocessor: J and Beyond 2013Andrea Tarr
 
CSS with LESS for #jd13nl
CSS with LESS for #jd13nlCSS with LESS for #jd13nl
CSS with LESS for #jd13nlHans Kuijpers
 

Was ist angesagt? (20)

SASS is more than LESS
SASS is more than LESSSASS is more than LESS
SASS is more than LESS
 
From PSD to WordPress Theme: Bringing designs to life
From PSD to WordPress Theme: Bringing designs to lifeFrom PSD to WordPress Theme: Bringing designs to life
From PSD to WordPress Theme: Bringing designs to life
 
CSS'in Gücü Adına
CSS'in Gücü AdınaCSS'in Gücü Adına
CSS'in Gücü Adına
 
LESS
LESSLESS
LESS
 
Theme04
Theme04Theme04
Theme04
 
Accelerated Stylesheets
Accelerated StylesheetsAccelerated Stylesheets
Accelerated Stylesheets
 
Modularization css with sass
Modularization css with sassModularization css with sass
Modularization css with sass
 
Sass compass
Sass compassSass compass
Sass compass
 
Front-End Dev Tools
Front-End Dev ToolsFront-End Dev Tools
Front-End Dev Tools
 
Theme01
Theme01Theme01
Theme01
 
Doing More With Less
Doing More With LessDoing More With Less
Doing More With Less
 
Compass/Sass
Compass/SassCompass/Sass
Compass/Sass
 
Sass, Compass and the new tools - Open Web Camp IV
Sass, Compass and the new tools - Open Web Camp IVSass, Compass and the new tools - Open Web Camp IV
Sass, Compass and the new tools - Open Web Camp IV
 
Theme 23
Theme 23Theme 23
Theme 23
 
This is a test
This is a testThis is a test
This is a test
 
Css frameworks
Css frameworksCss frameworks
Css frameworks
 
LESS, the CSS Preprocessor
LESS, the CSS PreprocessorLESS, the CSS Preprocessor
LESS, the CSS Preprocessor
 
Using LESS, the CSS Preprocessor: J and Beyond 2013
Using LESS, the CSS Preprocessor: J and Beyond 2013Using LESS, the CSS Preprocessor: J and Beyond 2013
Using LESS, the CSS Preprocessor: J and Beyond 2013
 
CSS with LESS for #jd13nl
CSS with LESS for #jd13nlCSS with LESS for #jd13nl
CSS with LESS for #jd13nl
 
Sass Essentials
Sass EssentialsSass Essentials
Sass Essentials
 

Andere mochten auch

Merancang penerbitanbahan video untuk pengajaran
Merancang penerbitanbahan video untuk pengajaranMerancang penerbitanbahan video untuk pengajaran
Merancang penerbitanbahan video untuk pengajaranSnexon Jajan Maria
 
New microsoft power point presentation
New microsoft power point presentationNew microsoft power point presentation
New microsoft power point presentationSnexon Jajan Maria
 
Radio-frequency_identification‎
Radio-frequency_identification‎ Radio-frequency_identification‎
Radio-frequency_identification‎ Mubashir Hassan
 

Andere mochten auch (6)

Merancang penerbitanbahan video untuk pengajaran
Merancang penerbitanbahan video untuk pengajaranMerancang penerbitanbahan video untuk pengajaran
Merancang penerbitanbahan video untuk pengajaran
 
Mapkinds
MapkindsMapkinds
Mapkinds
 
New microsoft power point presentation
New microsoft power point presentationNew microsoft power point presentation
New microsoft power point presentation
 
Install
InstallInstall
Install
 
RECONNECT
RECONNECTRECONNECT
RECONNECT
 
Radio-frequency_identification‎
Radio-frequency_identification‎ Radio-frequency_identification‎
Radio-frequency_identification‎
 

Ähnlich wie Sass & Compass (Barcamp Stuttgart 2012)

Sass and Compass - Getting Started
Sass and Compass - Getting StartedSass and Compass - Getting Started
Sass and Compass - Getting Startededgincvg
 
SASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockSASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockMarco Pinheiro
 
Preprocessor presentation
Preprocessor presentationPreprocessor presentation
Preprocessor presentationMario Noble
 
Using Sass - Building on CSS
Using Sass - Building on CSSUsing Sass - Building on CSS
Using Sass - Building on CSSSayanee Basu
 
Rapid Prototyping
Rapid PrototypingRapid Prototyping
Rapid PrototypingEven Wu
 
CSS3 is Not Magic Pixie Dust
CSS3 is Not Magic Pixie DustCSS3 is Not Magic Pixie Dust
CSS3 is Not Magic Pixie DustKyle Adams
 
LESS : The dynamic stylesheet language
LESS : The dynamic stylesheet languageLESS : The dynamic stylesheet language
LESS : The dynamic stylesheet languageKatsunori Tanaka
 
Mobile-first OOCSS, Sass & Compass at BBC Responsive News
Mobile-first OOCSS, Sass & Compass at BBC Responsive NewsMobile-first OOCSS, Sass & Compass at BBC Responsive News
Mobile-first OOCSS, Sass & Compass at BBC Responsive NewsKaelig Deloumeau-Prigent
 
Palestra pré processadores CSS
Palestra pré processadores CSSPalestra pré processadores CSS
Palestra pré processadores CSSJust Digital
 
Sassive Aggressive: Using Sass to Make Your Life Easier (Refresh Boston Version)
Sassive Aggressive: Using Sass to Make Your Life Easier (Refresh Boston Version)Sassive Aggressive: Using Sass to Make Your Life Easier (Refresh Boston Version)
Sassive Aggressive: Using Sass to Make Your Life Easier (Refresh Boston Version)Adam Darowski
 
Simple introduction Sass
Simple introduction SassSimple introduction Sass
Simple introduction SassZeeshan Ahmed
 
Learn Sass and Compass quick
Learn Sass and Compass quickLearn Sass and Compass quick
Learn Sass and Compass quickBilly Shih
 
CSSプリプロセッサの取扱説明書
CSSプリプロセッサの取扱説明書CSSプリプロセッサの取扱説明書
CSSプリプロセッサの取扱説明書拓樹 谷
 
CSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassCSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassLucien Lee
 
Brian Hoke: WordCamp Toronto 2014 Presentation "Sass & WordPress"
Brian Hoke: WordCamp Toronto 2014 Presentation "Sass & WordPress"Brian Hoke: WordCamp Toronto 2014 Presentation "Sass & WordPress"
Brian Hoke: WordCamp Toronto 2014 Presentation "Sass & WordPress"bentleyhoke
 

Ähnlich wie Sass & Compass (Barcamp Stuttgart 2012) (20)

Sass and Compass - Getting Started
Sass and Compass - Getting StartedSass and Compass - Getting Started
Sass and Compass - Getting Started
 
SASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockSASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, Greensock
 
Preprocessor presentation
Preprocessor presentationPreprocessor presentation
Preprocessor presentation
 
Using Sass - Building on CSS
Using Sass - Building on CSSUsing Sass - Building on CSS
Using Sass - Building on CSS
 
Rapid Prototyping
Rapid PrototypingRapid Prototyping
Rapid Prototyping
 
CSS3 is Not Magic Pixie Dust
CSS3 is Not Magic Pixie DustCSS3 is Not Magic Pixie Dust
CSS3 is Not Magic Pixie Dust
 
LESS : The dynamic stylesheet language
LESS : The dynamic stylesheet languageLESS : The dynamic stylesheet language
LESS : The dynamic stylesheet language
 
CSS3
CSS3CSS3
CSS3
 
PostCss
PostCssPostCss
PostCss
 
Mobile-first OOCSS, Sass & Compass at BBC Responsive News
Mobile-first OOCSS, Sass & Compass at BBC Responsive NewsMobile-first OOCSS, Sass & Compass at BBC Responsive News
Mobile-first OOCSS, Sass & Compass at BBC Responsive News
 
Palestra pré processadores CSS
Palestra pré processadores CSSPalestra pré processadores CSS
Palestra pré processadores CSS
 
Sassive Aggressive: Using Sass to Make Your Life Easier (Refresh Boston Version)
Sassive Aggressive: Using Sass to Make Your Life Easier (Refresh Boston Version)Sassive Aggressive: Using Sass to Make Your Life Easier (Refresh Boston Version)
Sassive Aggressive: Using Sass to Make Your Life Easier (Refresh Boston Version)
 
Simple introduction Sass
Simple introduction SassSimple introduction Sass
Simple introduction Sass
 
Less css
Less cssLess css
Less css
 
Learn Sass and Compass quick
Learn Sass and Compass quickLearn Sass and Compass quick
Learn Sass and Compass quick
 
CSSプリプロセッサの取扱説明書
CSSプリプロセッサの取扱説明書CSSプリプロセッサの取扱説明書
CSSプリプロセッサの取扱説明書
 
Intro to SASS CSS
Intro to SASS CSSIntro to SASS CSS
Intro to SASS CSS
 
CSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassCSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & Compass
 
Brian Hoke: WordCamp Toronto 2014 Presentation "Sass & WordPress"
Brian Hoke: WordCamp Toronto 2014 Presentation "Sass & WordPress"Brian Hoke: WordCamp Toronto 2014 Presentation "Sass & WordPress"
Brian Hoke: WordCamp Toronto 2014 Presentation "Sass & WordPress"
 
SASS Lecture
SASS Lecture SASS Lecture
SASS Lecture
 

Kürzlich hochgeladen

CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAnitaRaj43
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard37
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 

Kürzlich hochgeladen (20)

CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 

Sass & Compass (Barcamp Stuttgart 2012)

  • 1.
  • 2. schöneres CSS mit Sass & Compass
  • 4. Install & Run $ gem install sass $ sass --watch style.sass:style.css $ sass --watch assets/sass:public/css
  • 5. Basic Syntax css scss sass
  • 6. Nesting SASS article border-top: 1px dashed #eee header margin-bottom: 15px header, section color: #eee CSS article { border-top: 1px dashed #eeeeee; } article header { margin-bottom: 15px; } article header, article section { color: #eeeeee; }
  • 7. Parent Selector SASS article color: #f00 &:hover color: #00f .special & h1 font-size: 2em CSS article { color: red; } article:hover { color: blue; } .special article h1 { font-size: 2em; }
  • 8. @media SASS #content margin: 0 1.5em @media screen and (min-width: 1280px) margin: 0 2.5em CSS #content { margin: 0 1.5em; } @media screen and (min-width: 1280px) { #content { margin: 0 2.5em; } }
  • 9. Variablen SASS $link-color: #e78a15 $link-hover: #138a1e $link-size: 0.8em a color: $link-color font-size: $link-size &:hover color: $link-hover CSS a { color: #e78a15; font-size: 0.8em; } a:hover { color: #138a1e; }
  • 10. Weiterverwendung mit @extend SASS .button background-color: #00f color: #fff padding: 2em 1.5em .button-delete @extend .button background-color: #f00 CSS .button, .button-delete { background-color: blue; color: white; padding: 2em 1.5em; } .button-delete { background-color: red; }
  • 11. Vorlagen mit @mixin SASS @mixin hover-link text-decoration: none &:hover text-decoration: underline article a @include hover-link .nav a color: blue @include hover-link CSS article a { text-decoration: none; } article a:hover { text-decoration: underline; } .nav a { color: blue; text-decoration: none; } .nav a:hover { text-decoration: underline; }
  • 12. Funktionen mit @mixin SASS @mixin border-radius($amount) border-radius: $amount -mox-border-radius: $amount -webkit-border-radius: $amount .alert @include border-radius(5px) CSS .alert { border-radius: 5px; -mox-border-radius: 5px; -webkit-border-radius: 5px; }
  • 13. benannte Argumente mit @mixin SASS @mixin flash-message($bgcolor:red, $hovercolor:blue) background-color: $bgcolor &:hover background-color: $hovercolor .alertbox @include flash-message($hovercolor: green) CSS .alertbox { background-color: red; } .alertbox:hover { background-color: green; }
  • 14. Import pages/ _user.sass screen.sass _variables.sass _grid.sass _typography.sass _phone.sass SASS /* screen.sass */ @import "variables" @import "grid" @import "grid", "typography" @media screen and (min-width: 480px) @import "phone" #user @import "pages/user"
  • 15. etwas Mathematik SASS font-size: 18px - 5px width: 200px * 3 Beispiel: $layout-space: 10px $sidebar-width: 250px $page-width: 960px #main width: $page-width - $sidebar-width - (2 * $layout-space) CSS #main { width: 690px; }
  • 16. Mathematische Funktionen abs(-43) // => 43 floor(3.9) // => 3 ceil(3.2) // => 4 round(2.8) // => 3 percentage(13/25) // => 52%
  • 17. Mehr ... - Bedingungen (@if, @else, @elseif) - Logische Operatoren (<, >, >=, <=, ==, !=) - Verknuepfungen (and, or) - Schleifen (@for, @while, @each) - Farb-Inspektoren (hue, saturation, lightness, ..) - Farb-Funktionen (invert, mix, grayscale, darken, ..) - eigene Funktionen (@function) ...
  • 19. Installation $ gem install compass $ compass create my_project $ cd my_project $ vim config.rb $ compass watch oder $ sass --compass --watch assets/sass:public/css
  • 20. Cross Browser CSS3 Mixins ● Appearance ● Filter ● Background Clip ● Font Face ● Background Origin ● Hyphenation ● Background Size ● Images (Gradients) ● Border Radius ● Inline Block ● Box ● Opacity ● Box Shadow ● CSS Regions ● Box Sizing ● Text Shadow ● Columns ● Transform ● Transition
  • 21. Beispiel CSS3 Mixins SASS @import "compass" .flash-message @include background(linear-gradient(#fff, #eee)) @include border-radius(5px) CSS .flash-message { background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #ffffff), color-stop(100%, #eeeeee)); background: -webkit-linear-gradient(#ffffff, #eeeeee); background: -moz-linear-gradient(#ffffff, #eeeeee); background: -o-linear-gradient(#ffffff, #eeeeee); background: linear-gradient(#ffffff, #eeeeee); -webkit- border-radius: 5px; -moz-border-radius: 5px; -ms- border-radius: 5px; -o-border-radius: 5px; border- radius: 5px; }
  • 22. Layout Helper Grid Background Grid als Seitenhintergrund mithilfe CSS3 Gradients Sticky Footer Footer am Seitenende Stretching Dimensionen eines Divs auf das Elternelement ausweiten
  • 23. Utilities Reset (global, einzelne Resets (Font, body, ..) Cross Browser Clearfix Cross Browser Floats has-layout Hacks ...
  • 24. Sprites SASS @import "compass" @import "social/*.png" @include all-social-sprites CSS .icons-sprite, .icons-facebook, .icons-flickr, .icons- twitter, .icons-xing { background: url('/images/icons- s2d05e1e0af.png') no-repeat; } .icons-facebook { background-position: 0 -48px; } .icons-flickr { background-position: 0 -16px; } .icons-twitter { background-position: 0 -32px; } .icons-xing { background-position: 0 0; }
  • 25. Informations ● Sass - sass-lang.com ● Sass Ruby on Rails Implementation github.com/rails/sass-rails ● Compass - compass-style.org ● Noch mehr Infos ○ 35 Great Resources for Compass and Sass ○ Sass & Compass: The future of stylesheets now ○ css2sass converter