26
Pré-processadores {CSS} por: Daniel Santos Developer

Palestra pré processadores CSS

Embed Size (px)

DESCRIPTION

Overview dos principais pré-processadores (pre-process) de CSS. Less, Compass, Saas. Daniel Santos - Developer na Just Digital

Citation preview

Page 1: Palestra pré processadores CSS

Pré-processadores {CSS}

por: Daniel SantosDeveloper

Page 2: Palestra pré processadores CSS

Por que usar umPré-processador?

Page 3: Palestra pré processadores CSS

Pré-processadores❏ Mixins

❏ Extend❏ Variables

❏ Helpers❏ Operations

❏ Media❏ Functions

❏ Nesting❏ Importing

❏ Conditions❏ Color function

Page 4: Palestra pré processadores CSS

Qual pré-processador usar?

Page 5: Palestra pré processadores CSS

Compilando Less no tempo de execução

<link rel=”stylesheet/less” type=”text/css” href=”style.less” />

<script type=”text/javascript” src=”js/less-1.1.3.min.js”></script>

Page 6: Palestra pré processadores CSS

Compilando Less para um arquivo .css

$ sudo apt-get install npm

$ sudo apt-get install node-less

$ npm install -g less

$ lessc style.less > style.css

Page 7: Palestra pré processadores CSS

EXEMPLO Less

@import Mixins

Parametric MixinsNested

Page 8: Palestra pré processadores CSS

@import url("http://fonts.googleapis.com/css?family=Joti+One");

.radius (@radius) {-webkit-border-radius: @radius;-moz-border-radius: @radius;-ms-border-radius: @radius;-o-border-radius: @radius;border-radius: @radius;

}

.texto{text-align: center;font-family: 'Joti One';margin: 0;font-weight: bold;

}

Page 9: Palestra pré processadores CSS

@import "mixin.less";

.body{background: hardlight(#ff6600, #cccccc);margin: 0 auto;padding: 20px;width: 960px;height: 400px;.radius(100px 60px 10px 75px);

}

h1{.texto;color: negation(#ff6600, #cccccc);margin-bottom: 50px;font-size: 40px;

}

p{.texto;color: difference(#ff6600, #0000ff);font-size: 20px;

}

Page 10: Palestra pré processadores CSS

EXEMPLO Sass

@import$variables@Extend

Page 11: Palestra pré processadores CSS

@import url("http://fonts.googleapis.com/css?family=Underdog")$preto: #000$azul: #0000ff$rosa: #ff00cc

bodymargin: 0padding: 0background: $pretoh1

color: $azulfont-family: 'Underdog'font-weight: boldtext-align: centerfont-size: 60px

p@extend h1font-size: 20pxfont-weight: normalcolor: $rosa

Page 12: Palestra pré processadores CSS

@import url("http://fonts.googleapis.com/css?family=Underdog");body {

margin: 0;padding: 0;background: black; }body h1, body p {

color: blue;font-family: "Underdog";font-weight: bold;text-align: center;font-size: 60px; }

body p {font-size: 20px;font-weight: normal;color: #ff00cc; }

Page 13: Palestra pré processadores CSS

Algumas bibliotecas do Saas?

Page 14: Palestra pré processadores CSS
Page 15: Palestra pré processadores CSS
Page 16: Palestra pré processadores CSS
Page 17: Palestra pré processadores CSS
Page 18: Palestra pré processadores CSS

EXEMPLO Compass

@ImportHelpers

$VariablesOperations

@Mixin@if, @else if, @else

@for

Page 19: Palestra pré processadores CSS

@import url("http://fonts.googleapis.com/css?family=Averia+Sans+Libre")@import "compass/css3"

$black : #000$white : #fff$paragrafo : #a2c999 - 40

@mixin condicao($teste: true)@if $teste == false

font-family: 'Averia Sans Libre'font-size: 40pxcolor: $whitetext-align: centermargin: 0 0 35px 0

@else if $teste == 1font-size: 30pxcolor: $paragrafotext-align: centerfont-weight: normalfont-family: arialmargin: 0 0 35px 0

@elsefont-size: 70pxcolor: #0000ff + $paragrafofont-family: "Courier New"margin: 0

Page 20: Palestra pré processadores CSS

@import mixin

.contentbackground: $black+border-radius(25px 60px 0 40px)width: 960pxheight: 300pxmargin: 0 auto

h1+condicao(false)

p+condicao(1)

.paragrafo+condicao

Page 21: Palestra pré processadores CSS

@import url("http://fonts.googleapis.com/css?family=Averia+Sans+Libre");.content {

background: black;-webkit-border-radius: 25px 60px 0 40px;-moz-border-radius: 25px 60px 0 40px;-ms-border-radius: 25px 60px 0 40px;-o-border-radius: 25px 60px 0 40px;border-radius: 25px 60px 0 40px;width: 960px;height: 300px;margin: 0 auto;

}.content h1 {

font-family: "Averia Sans Libre";font-size: 40px;color: white;text-align: center;margin: 0 0 35px 0;

}.content p {

font-size: 30px;color: #7aa171;text-align: center;font-weight: normal;font-family: arial;margin: 0 0 35px 0;

}.content .paragrafo {

font-size: 70px;color: #7aa1ff;font-family: "Courier New";margin: 0;

}

Page 22: Palestra pré processadores CSS

@import url("http://fonts.googleapis.com/css?family=Averia+Sans+Libre")@import "compass/css3"

$branco : #fff$verde : #00ff00$circulo: #0000ff - 80

$class: teste_for !default@for $i from 1 through 2

.#{$class}_#{$i}width: 100%height: 40pxbackground: $circulomargin-bottom: 40px+border-radius(40px)

Page 23: Palestra pré processadores CSS

@import mixin

.contentbackground: $branco+box-shadow($verde 6px 6px 40px)width: 960pxheight: 400pxmargin: 0 autopadding-top: 30px

Page 24: Palestra pré processadores CSS

@import url("http://fonts.googleapis.com/css?family=Averia+Sans+Libre");.teste_for_1 {

width: 100%;height: 40px;background: #0000af;margin-bottom: 40px;-webkit-border-radius: 40px;-moz-border-radius: 40px;-ms-border-radius: 40px;-o-border-radius: 40px;border-radius: 40px;

}.teste_for_2 {

width: 100%;height: 40px;background: #0000af;margin-bottom: 40px;-webkit-border-radius: 40px;-moz-border-radius: 40px;-ms-border-radius: 40px;-o-border-radius: 40px;border-radius: 40px;

}.content {

background: white;-webkit-box-shadow: green 6px 6px 40px;-moz-box-shadow: green 6px 6px 40px;box-shadow: green 6px 6px 40px;width: 960px;height: 400px;margin: 0 auto;padding-top: 30px;

}

Page 25: Palestra pré processadores CSS

@import url("http://fonts.googleapis.com/css?family=Averia+Sans+Libre");.teste_for_1 {

width: 100%;height: 40px;background: #0000af;margin-bottom: 40px;-webkit-border-radius: 40px;-moz-border-radius: 40px;-ms-border-radius: 40px;-o-border-radius: 40px;border-radius: 40px;

}.teste_for_2 {

width: 100%;height: 40px;background: #0000af;margin-bottom: 40px;-webkit-border-radius: 40px;-moz-border-radius: 40px;-ms-border-radius: 40px;-o-border-radius: 40px;border-radius: 40px;

}.content {

background: white;-webkit-box-shadow: green 6px 6px 40px;-moz-box-shadow: green 6px 6px 40px;box-shadow: green 6px 6px 40px;width: 960px;height: 400px;margin: 0 auto;padding-top: 30px;

}

Page 26: Palestra pré processadores CSS

OBRIGADO!!!

Daniel SantosDeveloper

[email protected]+55(11)5181-5170

www.justdigital.com.brhttp://blog.justdigital.com.br