Documente Academic
Documente Profesional
Documente Cultură
CSS3 Introduo
"Anterior Prximocaptulo"
CSS3opadromaisrecenteparaCSS.
CSS3totalmentecompatvelcomversesanteriorescom
versesanterioresdoCSS.
EstaseoensinasobreosnovosrecursosdoCSS3!
Mdulos CSS3
CSS3foidivididoem"mdulos".Elecontma"especificaoCSSvelho"(quefoi
divididoempedaosmenores).Almdisso,novosmdulossoadicionados.
AlgunsdosmdulosCSS3maisimportantessoosseguintes:
Seletores
ModelodeCaixa
FundoseFronteiras
OsvaloresdeimagemecontedoSubstitudo
Efeitosdetexto
2D/3DTransformaes
Animaes
LayoutdeColuna
Interfacedeusurio
AmaioriadasnovaspropriedadesCSS3soimplementadasemnavegadores
modernos.
"Anterior Prximocaptulo"
Copyright19992015byRefsnesData.AllRightsReserved.
1/1
30/12/2015 CSS3BordersCantosarredondados
Suporte navegador
Osnmerosnatabelaespecificaraprimeiraversodonavegadorquesuporta
totalmenteapropriedade.
Nmerosseguidoporwebkitoumozespecificaraprimeiraversoquetrabalhou
comumprefixo.
Property
Aquiestotrsexemplos:
1.Cantosarredondadosparaumelementocomumacordefundoespecificada:
1/6
30/12/2015 CSS3BordersCantosarredondados
Cantos
arredondados!
2.Cantosarredondadosparaumelementocomumaborda:
Cantos
arredondados!
3.Cantosarredondadosparaumelementodeumaimagemdefundocom:
Cantos
arredondados!
Aquiestocdigo:
Exemplo
#rcorners1{
borderradius:25px;
background:#73AD21;
padding:20px;
width:200px;
height:150px;
}
#rcorners2{
borderradius:25px;
border:2pxsolid#73AD21;
padding:20px;
width:200px;
height:150px;
2/6
30/12/2015 CSS3BordersCantosarredondados
}
#rcorners3{
borderradius:25px;
background:url(paper.gif);
backgroundposition:lefttop;
backgroundrepeat:repeat;
padding:20px;
width:200px;
height:150px;
}
Tentevocmesmo"
Noentanto,vocpodeespecificarcadacantoseparadamente,sedesejar.Aquiesto
asregras:
Quatrovalores:primeirovaloraplicaseapartesuperioresquerda,segundo
valoraplicaseapartesuperiordireita,oterceirovaloraplicaseaparteinferior
direitoe,emquartovaloraplicaseacantoinferioresquerdo
Trsvalores:primeirovaloraplicaseapartesuperioresquerda,segundovalor
aplicaseasuperiordireitoeinferioresquerdo,eterceirovaloraplicasea
inferiordireita
Doisvalores:primeirovalorrefereaocantosuperioresquerdoeinferiordireito,
eosegundovaloraplicasesuperiordireitoecantoinferioresquerdo
Umvalor:todososquatrocantossoarredondadosigualmente
Aquiestotrsexemplos:
1.Quatrovaloresborderradius:15px50px30px5px:
3/6
30/12/2015 CSS3BordersCantosarredondados
2.Trsvaloresborderradius:15px50px30px:
3.Doisvaloresborderradius:15px50px:
Aquiestocdigo:
Exemplo
#rcorners4{
borderradius:15px50px30px5px;
background:#73AD21;
padding:20px;
width:200px;
height:150px;
}
#rcorners5{
borderradius:15px50px30px;
background:#73AD21;
padding:20px;
width:200px;
height:150px;
}
4/6
30/12/2015 CSS3BordersCantosarredondados
#rcorners6{
borderradius:15px50px;
background:#73AD21;
padding:20px;
width:200px;
height:150px;
}
Tentevocmesmo"
Voctambmpodecriarcantoselpticas:
Exemplo
#rcorners7{
borderradius:50px/15px;
background:#73AD21;
padding:20px;
width:200px;
height:150px;
}
#rcorners8{
borderradius:15px/50px;
background:#73AD21;
padding:20px;
width:200px;
height:150px;
}
#rcorners9{
borderradius:50%;
background:#73AD21;
padding:20px;
width:200px;
height:150px;
}
Tentevocmesmo"
5/6
30/12/2015 CSS3BordersCantosarredondados
borderradius Ashorthandpropertyforsettingallthefourborder
**radiusproperties
bordertopleft Definestheshapeoftheborderofthetopleftcorner
radius
bordertopright Definestheshapeoftheborderofthetopright
radius corner
borderbottomright Definestheshapeoftheborderofthebottomright
radius corner
borderbottomleft Definestheshapeoftheborderofthebottomleft
radius corner
"Anterior Prximocaptulo"
Copyright19992015byRefsnesData.AllRightsReserved.
6/6
30/12/2015 CSS3BorderImagens
Suporte navegador
Osnmerosnatabelaespecificaraprimeiraversodonavegadorquesuporta
totalmenteapropriedade.
Nmerosseguidoporwebkit,moz,ouOespecificaraprimeiraversoque
trabalhoucomumprefixo.
Property
Apropriedadetemtrspartes:
1. Aimagemaserusadacomoafronteira
2. Ondecortaraimagem
1/5
30/12/2015 CSS3BorderImagens
3. Definaseasseesdomeiodeveserrepetidoouesticado
Vamosusaraseguinteimagem(chamadode"border.png"):
O borderimage propriedadelevaaimagemecortaoemnovesees,comoum
tabuleirodetictactoe.Emseguida,elecolocaoscantosnoscantos,easseesdo
meiosorepetidasouesticadavocespecificar.
Aqui,asseesmeiodaimagemsorepetidosparacriarafronteira:
Umaimagemcomoumabeira!
Aquiestocdigo:
Exemplo
#borderimg{
border:10pxsolidtransparent;
padding:15px;
webkitborderimage:url(border.png)30round;/*Safari3.1
5*/
oborderimage:url(border.png)30round;/*Opera1112.1*/
borderimage:url(border.png)30round;
}
Tentevocmesmo"
Aqui,asseesmeiodaimagemsoesticadosparacriarafronteira:
Umaimagemcomoumabeira!
Aquiestocdigo:
2/5
30/12/2015 CSS3BorderImagens
Exemplo
#borderimg{
border:10pxsolidtransparent;
padding:15px;
webkitborderimage:url(border.png)30stretch;/*Safari
3.15*/
oborderimage:url(border.png)30stretch;/*Opera1112.1
*/
borderimage:url(border.png)30stretch;
}
Tentevocmesmo"
Exemplo1:
borderimage:url(border.png)50rodada
Exemplo2:
borderimage:url(border.png)20%redonda
Exemplo3:
borderimage:url(border.png)30%redonda
3/5
30/12/2015 CSS3BorderImagens
Aquiestocdigo:
Exemplo
#borderimg1{
border:10pxsolidtransparent;
padding:15px;
webkitborderimage:url(border.png)50round;/*Safari3.1
5*/
oborderimage:url(border.png)50round;/*Opera1112.1*/
borderimage:url(border.png)50round;
}
#borderimg2{
border:10pxsolidtransparent;
padding:15px;
webkitborderimage:url(border.png)20%round;/*Safari
3.15*/
oborderimage:url(border.png)20%round;/*Opera1112.1
*/
borderimage:url(border.png)20%round;
}
#borderimg3{
border:10pxsolidtransparent;
padding:15px;
webkitborderimage:url(border.png)30%round;/*Safari
3.15*/
oborderimage:url(border.png)30%round;/*Opera1112.1
*/
borderimage:url(border.png)30%round;
}
Tentevocmesmo"
4/5
30/12/2015 CSS3BorderImagens
borderimage Ashorthandpropertyforsettingalltheborder
image*properties
borderimagesource Specifiesthepathtotheimagetobeusedasa
border
borderimageslice Specifieshowtoslicetheborderimage
borderimagewidth Specifiesthewidthsoftheborderimage
borderimageoutset Specifiestheamountbywhichtheborderimagearea
extendsbeyondtheborderbox
borderimagerepeat Specifieswhethertheborderimageshouldbe
repeated,roundedorstretched
"Anterior Prximocaptulo"
Copyright19992015byRefsnesData.AllRightsReserved.
5/5
30/12/2015 CSS3Fundos
CSS3 Fundos
"Anterior Prximocaptulo"
CSS3 Fundos
CSS3contmalgumasnovaspropriedadesfundo,quepermitemmaiorcontrole
doelementodefundo.
Nestecaptulo,vocaprendercomoadicionarvriasimagensdefundoparaum
elemento.
VoctambmvaiaprendersobreasseguintesnovaspropriedadesCSS3:
backgroundsize
backgroundorigem
backgroundclipe
Suporte navegador
Osnmerosnatabelaespecificaraprimeiraversodonavegadorquesuporta
totalmenteapropriedade.
Nmerosseguidoporwebkit,moz,ouOespecificaraprimeiraversoque
trabalhoucomumprefixo.
Property
1/8
30/12/2015 CSS3Fundos
Asdiferentesimagensdefundososeparadosporvrgulas,easimagensso
empilhadosemcimaunsdosoutros,emqueaprimeiraimagemmaisprximodo
espectador.
Oexemploaseguirtemduasimagensdefundo,aprimeiraimagemumaflor
(alinhadoparteinferioredireita)easegundaimagemumfundodepapel
(alinhadocomocantosuperioresquerdo):
Exemplo
#example1{
backgroundimage:url(img_flwr.gif),url(paper.gif);
backgroundposition:rightbottom,lefttop;
backgroundrepeat:norepeat,repeat;
}
Tentevocmesmo"
Vriasimagensdefundopodemserespecificadosutilizandoaspropriedadesdefundo
individuais(comoacima)ouo fundo propriedadeestenogrfica.
Exemplo
#example1{
background:url(img_flwr.gif)rightbottomnorepeat,
url(paper.gif)lefttoprepeat;
2/8
30/12/2015 CSS3Fundos
Tentevocmesmo"
AntesCSS3,otamanhodeumaimagemdefundoeraotamanhorealdaimagem.
CSS3nospermitevoltarausarimagensdefundoemdiferentescontextos.
Otamanhopodeserespecificadoemcomprimentos,porcentagens,ouusandouma
dasduaspalavraschave:conteroutampa.
Oexemploaseguirredimensionaumaimagemdefundoparamuitomenoresdoque
aimagemoriginal(usandopixels):
Imagemdefundooriginal:
Utwisienimannciomnimaveniam,Quisnostrudexerciullamcorpertao
suscipitlobortisNISLutaliquipexeacommodoconsequat.
Backgroundimageredimensionada:
Utwisienimannciomnimaveniam,Quisnostrudexerciullamcorpertao
3/8
30/12/2015 CSS3Fundos
suscipitlobortisNISLutaliquipexeacommodoconsequat.
Aquiestocdigo:
Exemplo
#div1{
background:url(img_flower.jpg);
backgroundsize:100px80px;
backgroundrepeat:norepeat;
}
Tentevocmesmo"
O contm palavraschavedimensionaaimagemdefundoasertograndequanto
possvel(mastantoasualarguraesuaalturadevecaberdentrodareade
contedo).Comotal,dependendodasproporesdaimagemdefundoeazonade
posicionamentodofundo,podehaveralgumasreasdoplanodefundo,queno
estocobertaspelaimagemdefundo.
A tampa palavrachavedimensionaaimagemdefundoparaqueareadecontedo
completamentecobertapelaimagemdefundo(ambossualarguraealturaso
iguaisouexcedemareadecontedo).Comotal,algumaspartesdaimagemde
fundopodenoservisveisnareadeposicionamentodofundo.
Exemplo
#div1{
background:url(img_flower.jpg);
backgroundsize:contain;
backgroundrepeat:norepeat;
}
#div2{
background:url(img_flower.jpg);
4/8
30/12/2015 CSS3Fundos
backgroundsize:cover;
backgroundrepeat:norepeat;
}
Tentevocmesmo"
Oexemploaseguirtemtrsimagensdefundoespecificado,comdiferentevalorde
fundodetamanhoparacadaimagem:
Exemplo
#example1{
background:url(img_flwr.gif)lefttopnorepeat,
url(img_flwr.gif)rightbottomnorepeat,url(paper.gif)lefttop
repeat;
backgroundsize:50px,130px,auto;
}
Tentevocmesmo"
Osrequisitossoosseguintes:
Preenchatodaapginacomaimagem(nenhumespaoembranco)
Escaladaimagem,conformenecessrio
Imagemcentralnapgina
Nocausambarrasderolagem
5/8
30/12/2015 CSS3Fundos
OexemploaseguirmostracomofazloUseoelementohtml(oelementohtml
semprepelomenosaalturadajaneladonavegador).Emseguida,definaumfundo
fixoecentradanela.Emseguida,ajustarseutamanhocomapropriedade
backgroundsize:
Exemplo
html{
background:url(img_flower.jpg)norepeatcentercenterfixed;
backgroundsize:cover;
}
Tentevocmesmo"
Apropriedadetemtrsvaloresdiferentes:
borderboxaimagemdefundocomeaapartirdocantosuperioresquerdoda
fronteira
paddingbox(padro)aimagemdefundocomeaapartirdocantosuperior
esquerdodabordaestofamento
contentboxaimagemdefundocomeaapartirdocantosuperioresquerdodo
contedo
Exemplo
#example1{
border:10pxsolidblack;
padding:35px;
background:url(img_flwr.gif);
backgroundrepeat:norepeat;
backgroundorigin:contentbox;
}
6/8
30/12/2015 CSS3Fundos
Tentevocmesmo"
Apropriedadetemtrsvaloresdiferentes:
borderbox(padro)ofundopintadoparaabordaexternadafronteira
paddingboxofundopintadoparaabordaexternadoestofamento
contedodecaixaofundopintadodentrodacaixadecontedo
Exemplo
#example1{
border:10pxdottedblack;
padding:35px;
background:yellow;
backgroundclip:contentbox;
}
Tentevocmesmo"
Exerccio5
7/8
30/12/2015 CSS3Fundos
background Ashorthandpropertyforsettingallthebackground
propertiesinonedeclaration
backgroundclip Specifiesthepaintingareaofthebackground
backgroundimage Specifiesoneormorebackgroundimagesforan
element
backgroundorigin Specifieswherethebackgroundimage(s)is/are
positioned
backgroundsize Specifiesthesizeofthebackgroundimage(s)
"Anterior Prximocaptulo"
Copyright19992015byRefsnesData.AllRightsReserved.
8/8
30/12/2015 CSS3Colors
CSS3 Colors
"Anterior Prximocaptulo"
CSS3 Colors
CSSoferecesuporteanomesdecores,hexadecimalecoresRGB.
Almdisso,tambmintroduzCSS3:
CoresRGBA
CoresHSL
CoresHSLA
opacidade
Suporte navegador
Osnmerosnatabelaespecificaraprimeiraversodonavegadorquesuporta
totalmenteosvaloresdecorCSS3/propriedade.
Property
RGBA Colors
ValoresdecorRGBAsoumaextensodosvaloresdecorRGBcomumcanalalfa
queespecificaaopacidadedeumacor.
UmvalordecorRGBAespecificadocom:rgba(vermelho,verde,azul,alfa).O
parmetroalfaumnmeroentre0.0(totalmentetransparente)e1,0(totalmente
opaco).
rgba(255,0,0,0,2)
1/4
30/12/2015 CSS3Colors
rgba(255,0,0,0,4)
rgba(255,0,0,0,6)
rgba(255,0,0,0,8)
OexemploaseguirdefinediferentescoresRGBA:
Exemplo
#p1{backgroundcolor:rgba(255,0,0,0.3);}/*redwithopacity
*/
#p2{backgroundcolor:rgba(0,255,0,0.3);}/*greenwith
opacity*/
#p3{backgroundcolor:rgba(0,0,255,0.3);}/*bluewith
opacity*/
Tentevocmesmo"
HSL Colors
HSLsignificamatiz,saturaoeleveza.
UmvalordecorHSLespecificadocom:HSL(matiz,saturao,luminosidade).
1. Hueumgraunarodadecor(de0a360):
0(ou360)vermelho
120verde
240azul
2. Asaturaoumvalorpercentual:100%acorcompleta.
3. Levezatambmumapercentagem0%escuro(preto),e100%branco.
HSL(0,100%,30%)
HSL(0,100%,50%)
HSL(0,100%,70%)
HSL(0,100%,90%)
OexemploaseguirdefinediferentescoresHSL:
Exemplo
2/4
30/12/2015 CSS3Colors
#p1{backgroundcolor:hsl(120,100%,50%);}/*green*/
#p2{backgroundcolor:hsl(120,100%,75%);}/*lightgreen*/
#p3{backgroundcolor:hsl(120,100%,25%);}/*darkgreen*/
#p4{backgroundcolor:hsl(120,60%,70%);}/*pastelgreen*/
Tentevocmesmo"
HSLA Colors
ValoresdecorHSLAsoumaextensodosvaloresdecoresHSLcomumcanalalfa
queespecificaaopacidadedeumacor.
UmvalordecorHSLAespecificadocom:HSLA(tonalidade,asaturao,aleveza,
alfa),emqueoparmetroalfadefineaopacidade.Oparmetroalfaumnmero
entre0.0(totalmentetransparente)e1,0(totalmenteopaco).
HSLA(0,100%,30%,0,3)
HSLA(0,100%,50%,0,3)
HSLA(0,100%,70%,0,3)
HSLA(0,100%,90%,0,3)
OexemploaseguirdefinediferentescoresHSLA:
Exemplo
#p1{backgroundcolor:hsla(120,100%,50%,0.3);}/*greenwith
opacity*/
#p2{backgroundcolor:hsla(120,100%,75%,0.3);}/*lightgreen
withopacity*/
#p3{backgroundcolor:hsla(120,100%,25%,0.3);}/*darkgreen
withopacity*/
#p4{backgroundcolor:hsla(120,60%,70%,0.3);}/*pastel
greenwithopacity*/
Tentevocmesmo"
Opacidade
3/4
30/12/2015 CSS3Colors
ApropriedadeCSS3opacidadedefineaopacidadeparaumvalorRGBespecificada.
Ovalordapropriedadeopacidadedeveserumnmeroentre0.0(totalmente
transparente)e1.0(totalmenteopaco).
RGB(255,0,0)opacidade:0,2
RGB(255,0,0)opacidade:0,4
RGB(255,0,0)opacidade:0,6
RGB(255,0,0)opacidade:0,8
Observequeotextoacimatambmseropaca.
OexemploaseguirmostradiferentesvaloresRGBcomopacidade:
Exemplo
#p1{backgroundcolor:rgb(255,0,0);opacity:0.6;}/*redwith
opacity*/
#p2{backgroundcolor:rgb(0,255,0);opacity:0.6;}/*greenwith
opacity*/
#p3{backgroundcolor:rgb(0,0,255);opacity:0.6;}/*bluewith
opacity*/
Tentevocmesmo"
"Anterior Prximocaptulo"
Copyright19992015byRefsnesData.AllRightsReserved.
4/4
30/12/2015 OsgradientesCSS3
CSS3 gradientes
"Anterior Prximocaptulo"
BackgroundGradient
GradientesCSS3permitemexibirtransiessuavesentredoisoumaismodelos
especificadoscores.
Anteriormente,voctinhaqueusarasimagensparaestesefeitos.Noentanto,
usandogradientesCSS3vocpodereduzirotempodedownloadeusodebanda.
Almdisso,elementoscomgradientesolharmelhorquandoampliada,porqueo
gradientegeradopelonavegador.
CSS3definedoistiposdegradientes:
Osgradienteslineares(vaiparacima/baixo/esquerda/direita/
diagonal)
Osgradientesradiais(definidopeloseucentro)
Suporte navegador
Osnmerosnatabelaespecificaraprimeiraversodonavegadorquesuporta
totalmenteapropriedade.
Nmerosseguidoporwebkit,moz,ouOespecificaraprimeiraversoque
trabalhoucomumprefixo.
1/14
30/12/2015 OsgradientesCSS3
Property
Sintaxe
background:lineargradient(direction,colorstop1,colorstop2,
...);
GradienteLinearDecimaparabaixo(esteopadro)
Oexemploaseguirmostraumgradientelinearquecomeanotopo.Elecomeaa
vermelho,atransioparaoamarelo:
2/14
30/12/2015 OsgradientesCSS3
Exemplo
#grad{
background:red;/*Forbrowsersthatdonotsupportgradients
*/
background:webkitlineargradient(red,yellow);/*For
Safari5.1to6.0*/
background:olineargradient(red,yellow);/*ForOpera11.1
to12.0*/
background:mozlineargradient(red,yellow);/*ForFirefox
3.6to15*/
background:lineargradient(red,yellow);/*Standardsyntax
*/
}
Tentevocmesmo"
GradienteLinearesquerdaparaadireita
Oexemploaseguirmostraumgradientelinearquecomeaapartirdaesquerda.Ele
comeaavermelho,atransioparaoamarelo:
Exemplo
#grad{
background:red;/*Forbrowsersthatdonotsupportgradients
*/
background:webkitlineargradient(left,red,yellow);/*For
Safari5.1to6.0*/
background:olineargradient(right,red,yellow);/*ForOpera
11.1to12.0*/
background:mozlineargradient(right,red,yellow);/*For
Firefox3.6to15*/
3/14
30/12/2015 OsgradientesCSS3
background:lineargradient(toright,red,yellow);/*Standard
syntax*/
}
Tentevocmesmo"
GradienteLinearDiagonal
Vocpodefazerumgradienteemdiagonal,especificandoambasasposiesde
partidahorizontaiseverticais.
Oexemploaseguirmostraumgradientelinearquecomeanocantosuperior
esquerdo(evaiparaocantoinferiordireito).Elecomeaavermelho,atransio
paraoamarelo:
Exemplo
#grad{
background:red;/*Forbrowsersthatdonotsupportgradients
*/
background:webkitlineargradient(lefttop,red,yellow);/*
ForSafari5.1to6.0*/
background:olineargradient(bottomright,red,yellow);/*
ForOpera11.1to12.0*/
background:mozlineargradient(bottomright,red,yellow);/*
ForFirefox3.6to15*/
background:lineargradient(tobottomright,red,yellow);/*
Standardsyntax*/
}
Tentevocmesmo"
4/14
30/12/2015 OsgradientesCSS3
Usando Angles
Sevocquisermaiscontrolesobreadireodogradiente,vocpodedefinirum
ngulo,emvezdeasdireespredefinidos(parabaixo,paracima,paraadireita,
paraaesquerda,paraadireitainferior,etc.).
Sintaxe
background:lineargradient(angle,colorstop1,colorstop2);
Onguloespecificadocomoumnguloentreumalinhahorizontalepelalinhade
gradiente.
Oexemploaseguirmostracomousarngulosemgradienteslineares:
Exemplo
#grad{
background:red;/*Forbrowsersthatdonotsupportgradients
*/
background:webkitlineargradient(90deg,red,yellow);/*For
Safari5.1to6.0*/
background:olineargradient(90deg,red,yellow);/*For
Opera11.1to12.0*/
background:mozlineargradient(90deg,red,yellow);/*For
Firefox3.6to15*/
background:lineargradient(90deg,red,yellow);/*Standard
syntax*/
}
Tentevocmesmo"
5/14
30/12/2015 OsgradientesCSS3
Exemplo
#grad{
background:red;/*Forbrowsersthatdonotsupportgradients
*/
background:webkitlineargradient(red,yellow,green);/*For
Safari5.1to6.0*/
background:olineargradient(red,yellow,green);/*ForOpera
11.1to12.0*/
background:mozlineargradient(red,yellow,green);/*For
Firefox3.6to15*/
background:lineargradient(red,yellow,green);/*Standard
syntax*/
}
Tentevocmesmo"
Oexemploseguintemostracomocriarumgradientelinear(daesquerdaparaa
direita)comacordoarcoriseumtexto:
BackgroundGradient
6/14
30/12/2015 OsgradientesCSS3
Exemplo
#grad{
background:red;/*Forbrowsersthatdonotsupportgradients
*/
/*ForSafari5.1to6.0*/
background:webkitlinear
gradient(left,red,orange,yellow,green,blue,indigo,violet);
/*ForOpera11.1to12.0*/
background:olinear
gradient(left,red,orange,yellow,green,blue,indigo,violet);
/*ForFx3.6to15*/
background:mozlinear
gradient(left,red,orange,yellow,green,blue,indigo,violet);
/*Standardsyntax*/
background:lineargradient(toright,
red,orange,yellow,green,blue,indigo,violet);
}
Tentevocmesmo"
Usando Transparncia
GradientesCSS3tambmsuportamatransparncia,oquepodeserusadoparacriar
efeitosdedesvanecimento.
Paraadicionartransparncia,nsusamosafunorgba()paradefiniroslimitesde
cor.Oltimoparmetronafunorgba()podeserumvalorde0a1,eeledefinea
transparnciadacor:0indicaumatransparnciatotal,1indicafullcolor(sem
transparncia).
Oexemploaseguirmostraumgradientelinearquecomeaapartirdaesquerda.Ele
comeatotalmentetransparente,atransioparaacorvermelhacompleta:
7/14
30/12/2015 OsgradientesCSS3
Exemplo
#grad{
background:red;/*Forbrowsersthatdonotsupportgradients
*/
background:webkitlinear
gradient(left,rgba(255,0,0,0),rgba(255,0,0,1));/*Safari5.16*/
background:olinear
gradient(right,rgba(255,0,0,0),rgba(255,0,0,1));/*Opera11.112*/
background:mozlinear
gradient(right,rgba(255,0,0,0),rgba(255,0,0,1));/*Fx3.615*/
background:lineargradient(toright,rgba(255,0,0,0),
rgba(255,0,0,1));/*Standard*/
}
Tentevocmesmo"
Exemplo
Umgradientelinearrepetindo:
#grad{
background:red;/*Forbrowsersthatdonotsupportgradients
*/
/*Safari5.1to6.0*/
background:webkitrepeatinglineargradient(red,yellow10%,
8/14
30/12/2015 OsgradientesCSS3
green20%);
/*Opera11.1to12.0*/
background:orepeatinglineargradient(red,yellow10%,green
20%);
/*Firefox3.6to15*/
background:mozrepeatinglineargradient(red,yellow10%,
green20%);
/*Standardsyntax*/
background:repeatinglineargradient(red,yellow10%,green
20%);
}
Tentevocmesmo"
Paracriarumgradienteradialvoctambmdevedefinir,pelomenos,duasparadas
decor.
Sintaxe
background:radialgradient(shapesizeatposition,startcolor,...,
lastcolor);
Porpadro,aformaelipse,otamanhomaisdistantecanto,eaposioocentro.
RadialGradientuniformementeespaadosCorStops(esteopadro)
Oexemploaseguirmostraumgradienteradialcomlimitesdecoruniformemente
espaados:
9/14
30/12/2015 OsgradientesCSS3
Exemplo
#grad{
background:red;/*Forbrowsersthatdonotsupportgradients
*/
background:webkitradialgradient(red,yellow,green);/*
Safari5.1to6.0*/
background:oradialgradient(red,yellow,green);/*ForOpera
11.6to12.0*/
background:mozradialgradient(red,yellow,green);/*For
Firefox3.6to15*/
background:radialgradient(red,yellow,green);/*Standard
syntax*/
}
Tentevocmesmo"
RadialGradientDiferentementeespaadoCorStops
Oexemploaseguirmostraumgradienteradialcomlimitesdecordiferente
espaados:
Exemplo
#grad{
background:red;/*Forbrowsersthatdonotsupportgradients
*/
background:webkitradialgradient(red5%,yellow15%,green
60%);/*Safari5.16.0*/
background:oradialgradient(red5%,yellow15%,green60%);
/*ForOpera11.612.0*/
background:mozradialgradient(red5%,yellow15%,green60%);
/*ForFirefox3.615*/
10/14
30/12/2015 OsgradientesCSS3
background:radialgradient(red5%,yellow15%,green60%);/*
Standardsyntax*/
}
Tentevocmesmo"
Definir Forma
Oparmetrodeformadefineaforma.Podelevarocrculovalorouelipse.Ovalor
padroelipse.
Oexemploaseguirmostraumgradienteradialcomaformadeumcrculo:
Exemplo
#grad{
background:red;/*Forbrowsersthatdonotsupportgradients
*/
background:webkitradialgradient(circle,red,yellow,green);
/*Safari*/
background:oradialgradient(circle,red,yellow,green);/*
Opera11.6to12.0*/
background:mozradialgradient(circle,red,yellow,green);/*
Firefox3.6to15*/
background:radialgradient(circle,red,yellow,green);/*
Standardsyntax*/
11/14
30/12/2015 OsgradientesCSS3
Tentevocmesmo"
maisprximodolado
doladomaisdistante
maisprximocanto
maisdistantecanto
Exemplo
Umgradienteradialcompalavraschavediferentestamanho:
#grad1{
background:red;/*Forbrowsersthatdonotsupportgradients
*/
/*Safari5.1to6.0*/
background:webkitradialgradient(60%55%,closestside,red,
yellow,black);
/*ForOpera11.6to12.0*/
background:oradialgradient(60%55%,closestside,red,
yellow,black);
/*ForFirefox3.6to15*/
background:mozradialgradient(60%55%,closestside,red,
yellow,black);
/*Standardsyntax*/
background:radialgradient(closestsideat60%55%,red,
yellow,black);
}
#grad2{
/*Safari5.1to6.0*/
background:webkitradialgradient(60%55%,farthestside,red,
yellow,black);
/*Opera11.6to12.0*/
background:oradialgradient(60%55%,farthestside,red,
12/14
30/12/2015 OsgradientesCSS3
yellow,black);
/*ForFirefox3.6to15*/
background:mozradialgradient(60%55%,farthestside,red,
yellow,black);
/*Standardsyntax*/
background:radialgradient(farthestsideat60%55%,red,
yellow,black);
}
Tentevocmesmo"
Exemplo
Umgradienteradialrepetir:
#grad{
background:red;/*Forbrowsersthatdonotsupportgradients
*/
/*ForSafari5.1to6.0*/
background:webkitrepeatingradialgradient(red,yellow10%,
green15%);
/*ForOpera11.6to12.0*/
background:orepeatingradialgradient(red,yellow10%,green
15%);
/*ForFirefox3.6to15*/
background:mozrepeatingradialgradient(red,yellow10%,
green15%);
/*Standardsyntax*/
13/14
30/12/2015 OsgradientesCSS3
background:repeatingradialgradient(red,yellow10%,green
15%);
}
Tentevocmesmo"
"Anterior Prximocaptulo"
Copyright19992015byRefsnesData.AllRightsReserved.
14/14
30/12/2015 CSS3EfeitosdeSombra
ComCSS3vocpodecriarefeitosde
sombra!
Nestecaptulo,vocaprendersobreasseguintespropriedades:
textshadow
boxshadow
Suporte navegador
Osnmerosnatabelaespecificaraprimeiraversodonavegadorquesuporta
totalmenteapropriedade.
Nmerosseguidoporwebkitoumozespecificaaprimeiraversoquetrabalhou
comumprefixo.
Property
1/6
30/12/2015 CSS3EfeitosdeSombra
Noseuusomaissimples,vocsespecificarasombrahorizontal(2px)easombra
vertical(2px):
Exemplo
h1{
textshadow:2px2px;
}
Tentevocmesmo"
Emseguida,adicioneumacorparaasombra:
Exemplo
h1{
textshadow:2px2pxred;
}
Tentevocmesmo"
Emseguida,adicioneumefeitodeborroparaasombra:
Exemplo
2/6
30/12/2015 CSS3EfeitosdeSombra
h1{
textshadow:2px2px5pxred;
}
Tentevocmesmo"
Oexemploaseguirmostraumtextobrancocomsombrapreta:
Exemplo
h1{
color:white;
textshadow:2px2px4px#000000;
}
Tentevocmesmo"
Oexemploaseguirmostraumfulgordenonvermelhosombra:
Exemplo
h1{
textshadow:003px#FF0000;
}
Tentevocmesmo"
Vrias Sombras
Paraadicionarmaisdeumasombraaotexto,vocpodeadicionarumalistade
3/6
30/12/2015 CSS3EfeitosdeSombra
sombras,separadosporvrgulas.
Oexemploaseguirmostraumfulgordenonsombravermelhoeazul:
Exemplo
h1{
textshadow:003px#FF0000,005px#0000FF;
}
Tentevocmesmo"
Oexemploaseguirmostraumtextoembrancocompreto,azul,azulescuroe
sombra:
Exemplo
h1{
color:white;
textshadow:1px1px2pxblack,0025pxblue,005px
darkblue;
}
Tentevocmesmo"
Noseuusomaissimples,vocsespecificarasombrahorizontalevertical,a
sombra:
4/6
30/12/2015 CSS3EfeitosdeSombra
Esteumamarelo<div>elemento
comumpretoboxshadow
Exemplo
div{
boxshadow:10px10px;
}
Tentevocmesmo"
Emseguida,adicioneumacorparaasombra:
Esteumamarelo<div>elemento
comumcinzaboxshadow
Exemplo
div{
boxshadow:10px10pxgrey;
}
Tentevocmesmo"
Emseguida,adicioneumefeitodeborroparaasombra:
Esteumamarelo<div>elemento
comumborrado,cinzentobox
shadow
5/6
30/12/2015 CSS3EfeitosdeSombra
Exemplo
div{
boxshadow:10px10px5pxgrey;
}
Tentevocmesmo"
Exerccio5
Property Description
boxshadow Addsoneormoreshadowstoanelement
textshadow Addsoneormoreshadowstoatext
"Anterior Prximocaptulo"
Copyright19992015byRefsnesData.AllRightsReserved.
6/6
30/12/2015 CSS3Texto
CSS3 Texto
"Anterior Prximocaptulo"
CSS3 Texto
CSS3contmvriosnovosrecursosdetexto.
Nestecaptulo,vocaprendersobreasseguintespropriedadesdotexto:
textestouro
wordwrap
palavrabreak
Suporte navegador
Osnmerosnatabelaespecificaraprimeiraversodonavegadorquesuporta
totalmenteapropriedade.
Nmerosseguidosporoespecificaraprimeiraversoquetrabalhoucomum
prefixo.
Property
Elepodesercortado:
1/5
30/12/2015 CSS3Texto
Istoalgumtextolongoquenovaicabernacaixa
ouelepodeserprocessadocomoumreticncias(...):
Istoalgumtextolongo
OcdigoCSScomosesegue:
Exemplo
p.test1{
whitespace:nowrap;
width:200px;
border:1pxsolid#000000;
overflow:hidden;
textoverflow:clip;
}
p.test2{
whitespace:nowrap;
width:200px;
border:1pxsolid#000000;
overflow:hidden;
textoverflow:ellipsis;
}
Tentevocmesmo"
Oexemploaseguirmostracomovocpodeexibirocontedotransbordadaquando
pairandosobreoelemento:
Exemplo
div.test:hover{
textoverflow:inherit;
overflow:visible;
}
Tentevocmesmo"
2/5
30/12/2015 CSS3Texto
Seumapalavramuitograndeparacaberdentrodeumarea,eleseexpandeno
exterior:
Estepargrafo
contmumapalavra
muitolonga:
thisisaveryveryveryveryveryverylongword.
Apalavralongavai
quebrarequebra
paraaprximalinha.
Apropriedadewordwrappermiteforarotextoparaembrulharmesmoqueisso
signifiqueadivisonomeiodeumapalavra:
Estepargrafo
contmumapalavra
muitolonga:
thisisaveryveryveryv
eryveryverylongword.
Apalavralongavai
quebrarequebra
paraaprximalinha.
OcdigoCSScomosesegue:
Exemplo
Permitirpalavrascompridasparasercapazdeserquebradoeembrulharparaa
prximalinha:
p{
wordwrap:breakword;
}
Tentevocmesmo"
3/5
30/12/2015 CSS3Texto
Estepargrafo
contmalgum
texto.Estalinha
vaiquebrarat
hfens.
Estepargrafoco
ntmalgumtext
o.Aslinhasvaiqu
ebraraqualquerp
ersonagem.
OcdigoCSScomosesegue:
Exemplo
p.test1{
wordbreak:keepall;
}
p.test2{
wordbreak:breakall;
}
Tentevocmesmo"
4/5
30/12/2015 CSS3Texto
Property Description
textalignlast Specifieshowtoalignthelastlineofatext
textemphasis Ashorthandforsettingtextemphasisstyleandtext
emphasiscolorinonedeclaration
textjustify Specifieshowjustifiedtextshouldbealignedand
spaced
textoverflow Specifieshowoverflowedcontentthatisnotdisplayed
shouldbesignaledtotheuser
wordbreak SpecifieslinebreakingrulesfornonCJKscripts
wordwrap Allowslongwordstobeabletobebrokenandwrap
ontothenextline
"Anterior Prximocaptulo"
Copyright19992015byRefsnesData.AllRightsReserved.
5/5
30/12/2015 CSS3WebFonts
Quandovoctiverencontrado/compradoafontequevocdesejausar,bastaincluir
oarquivodefontenoseuservidorweb,eeleserautomaticamentebaixadoparao
usurio,quandonecessrio.
Suporte navegador
Osnmerosnatabelaespecificaraprimeiraversodonavegadorquesuporta
totalmenteapropriedade.
Property
TrueTypeumpadrodefontedesenvolvidonofinalde1980,pelaAppleeMicrosoft.
TrueTypeoformatodafontemaiscomumparaambosossistemasoperacionais
MacOSeMicrosoftWindows.
OpenType(OTF)
1/5
30/12/2015 CSS3WebFonts
OpenTypeumformatoparafontesdecomputadorescalveis.Foiconstrudoem
TrueType,eumamarcacomercialregistradadaMicrosoft.AsfontesOpenTypeso
comumenteusadoshojenasprincipaisplataformasdecomputador.
OWebOpenFontFormat(WOFF)
WOFFumformatodefonteparausoempginasdaweb.Elefoidesenvolvidoem
2009,eagoraumaRecomendaoW3C.WOFFessencialmenteOpenTypeou
TrueTypecomcompressoemetadadosadicionais.Oobjetivoapoiaradistribuio
fonteapartirdeumservidorparaumclienteatravsdeumaredecomrestriesde
larguradebanda.
OWebOpenFontFormat(WOFF2.0)
TrueTypefont/OpenTypequeproporcionamelhorcompressodoqueWOFF1.0.
SVGFontes/Shapes
FontesSVGpermitirSVGparaserusadocomoglifosaoexibirtexto.Aespecificao
SVG1,1definirummdulodefontequepermiteacriaodefontesdentrodeum
documentoSVG.VoctambmpodeaplicarCSSparadocumentosSVG,earegra@
fontfacepodeseraplicadaaotextoemdocumentosSVG.
AsfontesOpenTypeembutidas(EOT)
FontesEOTsoumaformacompactadefontesOpenTypeprojetadospelaMicrosoft
parausocomofontesincorporadasempginasdaweb.
Font
format
*IE:Oformatodefontesfuncionaquandodefinidoparaser"instalvel".
*Firefox:Nosuportadoporpadro,maspodeserhabilitado(necessidadededefinir
umsinalizadorpara"true",parausarWOFF2).
Dica:SempreuseletrasminsculasparaoURLfonte.Letras
maisculaspodedarresultadosinesperadosnoIE.
ParausarafonteparaumelementoHTML,referemseaonomedafonte
(myFirstFont)atravsdo fontfamily propriedade:
Exemplo
@fontface{
fontfamily:myFirstFont;
src:url(sansation_light.woff);
}
div{
fontfamily:myFirstFont;
}
Tentevocmesmo"
3/5
30/12/2015 CSS3WebFonts
Exemplo
@fontface{
fontfamily:myFirstFont;
src:url(sansation_bold.woff);
fontweight:bold;
}
Tentevocmesmo"
Oarquivo"sansation_bold.woff"outroarquivodefonte,quecontmoscaracteres
emnegritoparaafonteSansation.
Browsersvaiusarissosemprequeumpedaodetextocomofontfamily
"myFirstFont"deveprocessarcomonegrito.
4/5
30/12/2015 CSS3WebFonts
semi
condensed
expanded
semi
expanded
extra
expanded
ultra
expanded
"Anterior Prximocaptulo"
Copyright19992015byRefsnesData.AllRightsReserved.
5/5
30/12/2015 CSS3Transformaes2D
CSS3 2D Transformaes
"Anterior Prximocaptulo"
CSS3 Transformaes
TransformaesCSS3permitirquevoctraduzir,girar,dimensionaredistorcer
elementos.
Atransformaoumefeitoquepermitequeumelementomudamdeforma,
tamanhoeposio.
CSS3suportatransformaes2De3D.
Passeomousesobreoselementosabaixoparaveradiferenaentreum2Deuma
transformao3D:
2D D3
girar rarig
Nmerosseguidosdems,webkit,moz,ouOespecificaraprimeiraversoque
trabalhoucomumprefixo.
Property
CSS3 Transformaes 2D
Nestecaptulo,vocaprendersobreosseguintesmtodosdetransformao2D:
traduzir()
rotate()
escala()
skewX()
skewY()
matriz()
Dica:Vocvaiaprendersobretransformaes3Dnoprximocaptulo.
O traduzir Mtodo
O traduzir() mtodomovimentaumelementodasuaposioactual(deacordo
comosparmetrosindicadosparaoeixoXeoeixoY).
Oexemploaseguirmoveoelemento<div>50pixelsparaadireita,e100pixels
parabaixodesuaposioatual:
Exemplo
div{
mstransform:translate(50px,100px);/*IE9*/
webkittransform:translate(50px,100px);/*Safari*/
transform:translate(50px,100px);
2/8
30/12/2015 CSS3Transformaes2D
Tentevocmesmo"
O rotate Mtodo
O rotate() mtodogiranosentidohorrioumelementoouantihorriode
acordocomumdeterminadograu.
Oexemploaseguirgiraoelemento<div>nosentidohorriocom20graus:
Exemplo
div{
mstransform:rotate(20deg);/*IE9*/
webkittransform:rotate(20deg);/*Safari*/
transform:rotate(20deg);
}
Tentevocmesmo"
Usandovaloresnegativosirrodaroelementoantihorrio.
Oexemploaseguirgiraoelemento<div>sentidoantihorriocom20graus:
Exemplo
div{
mstransform:rotate(20deg);/*IE9*/
webkittransform:rotate(20deg);/*Safari*/
transform:rotate(20deg);
}
3/8
30/12/2015 CSS3Transformaes2D
Tentevocmesmo"
O Mtodo de escala
Os scale() mtodoaumentaoudiminuiotamanhodeumelemento(deacordo
comosparmetrosdadosporalarguraealtura).
Oexemploaseguiraumentaoelemento<div>paraserduasvezesdesualargura
original,etrsvezesdesuaalturaoriginal:
Exemplo
div{
mstransform:scale(2,3);/*IE9*/
webkittransform:scale(2,3);/*Safari*/
transform:scale(2,3);
}
Tentevocmesmo"
Oexemploaseguirdiminuioelemento<div>paraserametadedasualargurae
alturaoriginal:
Exemplo
div{
mstransform:scale(0.5,0.5);/*IE9*/
webkittransform:scale(0.5,0.5);/*Safari*/
transform:scale(0.5,0.5);
4/8
30/12/2015 CSS3Transformaes2D
Tentevocmesmo"
O skewX Mtodo
O skewX() mtododistorceumelementoaolongodoeixoXpelongulodado.
Oexemploaseguirinclinaoelemento<div>20grausaolongodoeixoX:
Exemplo
div{
mstransform:skewX(20deg);/*IE9*/
webkittransform:skewX(20deg);/*Safari*/
transform:skewX(20deg);
}
Tentevocmesmo"
O skewY Mtodo
O skewY() mtododistorceumelementoaolongodoeixoYpelongulodado.
Oexemploaseguirinclinaoelemento<div>20grausaolongodoeixoY:
Exemplo
div{
mstransform:skewY(20deg);/*IE9*/
webkittransform:skewY(20deg);/*Safari*/
transform:skewY(20deg);
}
5/8
30/12/2015 CSS3Transformaes2D
Tentevocmesmo"
A inclinao Mtodo
A inclinao() mtododistorceumelementoaolongodoXedoeixoYpelos
ngulosdadas.
Oexemploaseguirdistorceoelemento<div>20grausaolongodoeixoX,e10
grausaolongodoeixoY:
Exemplo
div{
mstransform:skew(20deg,10deg);/*IE9*/
webkittransform:skew(20deg,10deg);/*Safari*/
transform:skew(20deg,10deg);
}
Tentevocmesmo"
Seosegundoparmetronoespecificado,eletemumvalordezero.Assim,o
exemploaseguirinclinaoelemento<div>20grausaolongodoeixoX:
Exemplo
div{
mstransform:skew(20deg);/*IE9*/
webkittransform:skew(20deg);/*Safari*/
transform:skew(20deg);
}
Tentevocmesmo"
A matriz Mtodo
6/8
30/12/2015 CSS3Transformaes2D
A matriz() mtodocombinatransformartodososmtodos2Demum.
Omtododematriz()levarseisparmetros,contendofunesmatemticas,oque
lhepermitegirar,redimensionar,mover(traduzir),edistorcerelementos:
Exemplo
div{
mstransform:matrix(1,0.3,0,1,0,0);/*IE9*/
webkittransform:matrix(1,0.3,0,1,0,0);/*Safari*/
transform:matrix(1,0.3,0,1,0,0);
}
Tentevocmesmo"
Property Description
transform Appliesa2Dor3Dtransformationtoanelement
transform Allowsyoutochangethepositionontransformed
origin elements
2D Transform Mtodos
7/8
30/12/2015 CSS3Transformaes2D
Function Description
matrix(n,n,n,n,n,n) Definesa2Dtransformation,usingamatrixofsix
values
translate(x,y) Definesa2Dtranslation,movingtheelementalongthe
XandtheYaxis
translateX(n) Definesa2Dtranslation,movingtheelementalongthe
Xaxis
translateY(n) Definesa2Dtranslation,movingtheelementalongthe
Yaxis
scale(x,y) Definesa2Dscaletransformation,changingthe
elementswidthandheight
scaleX(n) Definesa2Dscaletransformation,changingthe
element'swidth
scaleY(n) Definesa2Dscaletransformation,changingthe
element'sheight
rotate(angle) Definesa2Drotation,theangleisspecifiedinthe
parameter
skew(xangle,y Definesa2DskewtransformationalongtheXandthe
angle) Yaxis
skewX(angle) Definesa2DskewtransformationalongtheXaxis
skewY(angle) Definesa2DskewtransformationalongtheYaxis
"Anterior Prximocaptulo"
Copyright19992015byRefsnesData.AllRightsReserved.
8/8
30/12/2015 CSS3transformaes3D
CSS3 transformaes 3D
"Anterior Prximocaptulo"
CSS3 transformaes 3D
CSS3permitequevocformateseuselementosusandotransformaes3D.
Passeomousesobreoselementosabaixoparaveradiferenaentreum2Deuma
transformao3D:
2D 3D
girar girar
Nmerosseguidoporwebkit,moz,ouOespecificaraprimeiraversoque
trabalhoucomumprefixo.
Property
CSS3 transformaes 3D
Nestecaptulo,vocaprendersobreosseguintesmtodosdetransformao3D:
rotateX()
rotateY()
rotateZ()
O rotateX Mtodo
O rotateX() mtodogiraumelementoemtornodoseueixoXemum
determinadograu:
Exemplo
div{
webkittransform:rotateX(150deg);/*Safari*/
transform:rotateX(150deg);
}
Tentevocmesmo"
2/5
30/12/2015 CSS3transformaes3D
O rotateY Mtodo
O rotateY() mtodogiraumelementoemtornodoseueixoYemum
determinadograu:
Exemplo
div{
webkittransform:rotateY(130deg);/*Safari*/
transform:rotateY(130deg);
}
Tentevocmesmo"
O rotateZ Mtodo
O rotateZ() mtodogiraumelementoemtornodoseueixoZemum
determinadograu:
Exemplo
div{
webkittransform:rotateZ(90deg);/*Safari*/
transform:rotateZ(90deg);
}
Tentevocmesmo"
Property Description
transform Appliesa2Dor3Dtransformationtoanelement
transform Allowsyoutochangethepositionontransformedelements
origin
transform Specifieshownestedelementsarerenderedin3Dspace
style
perspective Specifiestheperspectiveonhow3Delementsareviewed
perspective Specifiesthebottompositionof3Delements
origin
backface Defineswhetherornotanelementshouldbevisiblewhen
visibility notfacingthescreen
3D Transform Mtodos
Function Description
matrix3d Definesa3Dtransformation,usinga4x4
(n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n) matrixof16values
translate3d(x,y,z) Definesa3Dtranslation
translateX(x) Definesa3Dtranslation,usingonlythe
valuefortheXaxis
translateY(y) Definesa3Dtranslation,usingonlythe
valuefortheYaxis
translateZ(z) Definesa3Dtranslation,usingonlythe
valuefortheZaxis
scale3d(x,y,z) Definesa3Dscaletransformation
scaleX(x) Definesa3Dscaletransformationby
givingavaluefortheXaxis
4/5
30/12/2015 CSS3transformaes3D
scaleY(y) Definesa3Dscaletransformationby
givingavaluefortheYaxis
scaleZ(z) Definesa3Dscaletransformationby
givingavaluefortheZaxis
rotate3d(x,y,z,angle) Definesa3Drotation
rotateX(angle) Definesa3DrotationalongtheXaxis
rotateY(angle) Definesa3DrotationalongtheYaxis
rotateZ(angle) Definesa3DrotationalongtheZaxis
perspective(n) Definesaperspectiveviewfora3D
transformedelement
"Anterior Prximocaptulo"
Copyright19992015byRefsnesData.AllRightsReserved.
5/5
30/12/2015 CSS3Transies
CSS3 Transies
"Anterior Prximocaptulo"
CSS3 Transies
TransiesCSS3permitequevocaltereosvaloresdepropriedadesemproblemas
(apartirdeumvalorparaoutro),duranteumdeterminadoperodo.
Exemplo:Passeomousesobreoelementoabaixoparaverumefeitodetransio
CSS3:
CSS3
Nmerosseguidoporwebkit,moz,ouOespecificaraprimeiraversoque
trabalhoucomumprefixo.
Property
apropriedadeCSSquevocdesejaadicionarumefeitoa
aduraodoefeito
Nota:Seaparteduraonoforespecificado,atransionoternenhumefeito,
porqueovalorpadro0.
Oexemploaseguirmostraum100px*100pxvermelho<div>elemento.O
elemento<div>tambmespecificouumefeitodetransioparaapropriedadede
largura,comumaduraode2segundos:
Exemplo
div{
width:100px;
height:100px;
background:red;
webkittransition:width2s;/*Safari*/
transition:width2s;
}
OefeitodetransioterincioquandoapropriedadeCSSespecificado(largura)
alteraovalor.
Agora,vamosespecificarumnovovalorparaapropriedadedelarguraquandoo
usuriopassaomousesobreoelemento<div>:
Exemplo
div:hover{
2/6
30/12/2015 CSS3Transies
width:300px;
}
Tentevocmesmo"
Observequequandoosmousescursorparaforadoelemento,elevaimudar
gradualmentedevoltaaseuestilooriginal.
Exemplo
div{
webkittransition:width2s,height4s;/*Safari*/
transition:width2s,height4s;
}
Tentevocmesmo"
Apropriedadetimingfunctiontransiopodeterosseguintesvalores:
facilidade especificaumefeitodetransiocomuminciolento,em
seguida,rapidamente,emseguida,terminarlentamente(esteopadro)
linear especificaumefeitodetransiocomamesmavelocidadedoincio
aofim
aliviarin especificaumefeitodetransiocomuminciolento
aliviarout especificaumefeitodetransiocomumfinallento
aliviarinout especificaumefeitodetransiocomumincioefim
3/6
30/12/2015 CSS3Transies
lento
cbicobezier(n,n,n,n) permitedefinirseusprpriosvaloresem
umafunocbicabezier
Oexemploaseguirmostraaalgumasdasdiferentescurvasdevelocidadeque
podemserutilizados:
Exemplo
#div1{transitiontimingfunction:linear;}
#div2{transitiontimingfunction:ease;}
#div3{transitiontimingfunction:easein;}
#div4{transitiontimingfunction:easeout;}
#div5{transitiontimingfunction:easeinout;}
Tentevocmesmo"
Oexemploaseguirtemumatrasode1segundoantesdepartida:
Exemplo
div{
webkittransitiondelay:1s;/*Safari*/
transitiondelay:1s;
}
Tentevocmesmo"
Transio + Transformation
Oexemploaseguiradicionatambmumatransformaoparaoefeitodetransio:
4/6
30/12/2015 CSS3Transies
Exemplo
div{
webkittransition:width2s,height2s,webkittransform2s;
/*Safari*/
transition:width2s,height2s,transform2s;
}
Tentevocmesmo"
Exemplo
div{
transitionproperty:width;
transitionduration:2s;
transitiontimingfunction:linear;
transitiondelay:1s;
}
Tentevocmesmo"
ouusandoapropriedadeestenogrfica de transio:
Exemplo
div{
transition:width2slinear1s;
}
Tentevocmesmo"
5/6
30/12/2015 CSS3Transies
Exerccio5
Property Description
transition Ashorthandpropertyforsettingthefourtransition
propertiesintoasingleproperty
transitiondelay Specifiesadelay(inseconds)forthetransitioneffect
transition Specifieshowmanysecondsormillisecondsatransition
duration effecttakestocomplete
transition SpecifiesthenameoftheCSSpropertythetransition
property effectisfor
transition Specifiesthespeedcurveofthetransitioneffect
timingfunction
"Anterior Prximocaptulo"
Copyright19992015byRefsnesData.AllRightsReserved.
6/6
30/12/2015 CSS3animaes
CSS3 animaes
"Anterior Prximocaptulo"
CSS3 animaes
AnimaesCSS3permiteanimaodamaioriadoselementosHTMLsemautilizao
deJavaScriptouFlash!
CSS3
Animao
Nmerosseguidoporwebkit,moz,ouOespecificaraprimeiraversoque
trabalhoucomumprefixo.
Property
1/9
30/12/2015 CSS3animaes
VocpodemudarquantaspropriedadesCSSquequiser,quantasvezesquiser.
ParausaranimaoCSS3,vocdeveprimeiroespecificaralgunsquadroschavepara
aanimao.
Keyframesseguraroqueosestilosoelementoteremdeterminadosmomentos.
A Regrakeyframes
QuandovocespecificarestilosCSSdentro dokeyframes regra,aanimaoir
mudargradualmenteapartirdoestiloatualparaonovoestiloemdeterminados
momentos.
Paraseterumaanimaoparaotrabalho,vocdeveligaraanimaoaum
elemento.
Oexemploaseguirvinculao"exemplo"deanimaoparao<div>elemento.A
vontadedeanimaotemaduraode4segundos,eeleirgradualmentemudara
cordefundodoelemento<div>de"vermelho"para"amarelo":
Exemplo
/*Theanimationcode*/
@keyframesexample{
from{backgroundcolor:red;}
to{backgroundcolor:yellow;}
}
/*Theelementtoapplytheanimationto*/
div{
width:100px;
height:100px;
backgroundcolor:red;
animationname:example;
animationduration:4s;
}
Tentevocmesmo"
Noexemploacima,temosespecificadoquandooestilovaimudarusandoas
palavraschave"de"e"para"(querepresenta0%(incio)e100%(completo)).
Tambmpossvelutilizarporcento.Aousarporcento,vocpodeadicionarquantos
mudanasdeestilocomovocgosta.
Oexemploaseguiriralteraracordefundodoelemento<div>quandoaanimao
de25%completo,50%completo,enovamentequandoaanimaoest100%
concluda:
Exemplo
/*Theanimationcode*/
@keyframesexample{
0%{backgroundcolor:red;}
25%{backgroundcolor:yellow;}
50%{backgroundcolor:blue;}
100%{backgroundcolor:green;}
}
/*Theelementtoapplytheanimationto*/
div{
width:100px;
height:100px;
backgroundcolor:red;
animationname:example;
animationduration:4s;
}
Tentevocmesmo"
Oexemploaseguirvaimudartantoacordefundoeaposiodoelemento<div>
quandoaanimaode25%completo,50%completo,enovamentequandoa
animaoest100%concluda:
Exemplo
/*Theanimationcode*/
@keyframesexample{
0%{backgroundcolor:red;left:0px;top:0px;}
25%{backgroundcolor:yellow;left:200px;top:0px;}
3/9
30/12/2015 CSS3animaes
50%{backgroundcolor:blue;left:200px;top:200px;}
75%{backgroundcolor:green;left:0px;top:200px;}
100%{backgroundcolor:red;left:0px;top:0px;}
}
/*Theelementtoapplytheanimationto*/
div{
width:100px;
height:100px;
position:relative;
backgroundcolor:red;
animationname:example;
animationduration:4s;
}
Tentevocmesmo"
Oexemploqueseseguetemumatrasode2segundos,antesdeiniciaraanimao:
Exemplo
div{
width:100px;
height:100px;
position:relative;
backgroundcolor:red;
animationname:example;
animationduration:4s;
animationdelay:2s;
}
Tentevocmesmo"
4/9
30/12/2015 CSS3animaes
Oexemploaseguirirexecutaraanimao3vezesantesdeparar:
Exemplo
div{
width:100px;
height:100px;
position:relative;
backgroundcolor:red;
animationname:example;
animationduration:4s;
animationiterationcount:3;
}
Tentevocmesmo"
Oexemploaseguirusaovalor"infinito"parafazeraanimaocontinuepara
sempre
Exemplo
div{
width:100px;
height:100px;
position:relative;
backgroundcolor:red;
animationname:example;
animationduration:4s;
animationiterationcount:infinite;
}
5/9
30/12/2015 CSS3animaes
Tentevocmesmo"
Oexemploaseguirirexecutaraanimaonadireoinversa:
Exemplo
div{
width:100px;
height:100px;
position:relative;
backgroundcolor:red;
animationname:example;
animationduration:4s;
animationiterationcount:3;
animationdirection:reverse;
}
Tentevocmesmo"
Oexemploaseguirusaovalor"alternativo"parafazeraanimaoexecutadopela
primeiravezparaafrente,depoisparatrs,depoisparaafrente:
Exemplo
div{
width:100px;
height:100px;
position:relative;
backgroundcolor:red;
animationname:example;
6/9
30/12/2015 CSS3animaes
animationduration:4s;
animationiterationcount:3;
animationdirection:alternate;
}
Tentevocmesmo"
Apropriedadetimingfunctionanimaopodeterosseguintesvalores:
facilidade especificaumaanimaocomuminciolento,emseguida,
rapidamente,emseguida,terminarlentamente(esteopadro)
linear especificaumaanimaocomamesmavelocidadedoincioaofim
aliviarin especificaumaanimaocomuminciolento
aliviarout especificaumaanimaocomumfinallento
aliviarinout especificaumaanimaocomumcomeoefinallento
cbicobezier(n,n,n,n) permitedefinirseusprpriosvaloresem
umafunocbicabezier
Oexemploaseguirmostraaalgumasdasdiferentescurvasdevelocidadeque
podemserutilizados:
Exemplo
#div1{animationtimingfunction:linear;}
#div2{animationtimingfunction:ease;}
#div3{animationtimingfunction:easein;}
#div4{animationtimingfunction:easeout;}
#div5{animationtimingfunction:easeinout;}
Tentevocmesmo"
Oexemploabaixoutilizaseisdaspropriedadesdeanimao:
Exemplo
div{
animationname:example;
animationduration:5s;
animationtimingfunction:linear;
animationdelay:2s;
animationiterationcount:infinite;
animationdirection:alternate;
}
Tentevocmesmo"
Omesmoefeitodeanimaocomoacimapodeseralcanadoutilizandoaforma
abreviada deanimao propriedades:
Exemplo
div{
animation:example5slinear2sinfinitealternate;
}
Tentevocmesmo"
Exerccio5 Exerccio6
Atabelaaseguirlistaaregrakeyframesetodasaspropriedadesdeanimao:
Property Description
@keyframes Specifiestheanimationcode
animation Ashorthandpropertyforsettingalltheanimation
properties
animationdelay Specifiesadelayforthestartofananimation
animationdirection Specifieswhetherananimationshouldplayinreverse
directionoralternatecycles
animationduration Specifieshowmanysecondsormillisecondsan
animationtakestocompleteonecycle
animationfillmode Specifiesastylefortheelementwhentheanimationis
notplaying(whenitisfinished,orwhenithasadelay)
animationiteration Specifiesthenumberoftimesananimationshouldbe
count played
animationname Specifiesthenameofthe@keyframesanimation
animationplay Specifieswhethertheanimationisrunningorpaused
state
animationtiming Specifiesthespeedcurveoftheanimation
function
"Anterior Prximocaptulo"
Copyright19992015byRefsnesData.AllRightsReserved.
9/9
30/12/2015 CSSBotes
CSS Botes
"Anterior Prximocaptulo"
SaibacomoestilodebotesusandoCSS.
BotoPadro BotoCSS
Exemplo
.button{
backgroundcolor:#4CAF50;/*Green*/
border:none;
color:white;
padding:15px32px;
textalign:center;
textdecoration:none;
display:inlineblock;
fontsize:16px;
}
Tentevocmesmo"
Boto Cores
1/8
30/12/2015 CSSBotes
Exemplo
.button1{backgroundcolor:#4CAF50;}/*Green*/
.button2{backgroundcolor:#008CBA;}/*Blue*/
.button3{backgroundcolor:#f44336;}/*Red*/
.button4{backgroundcolor:#e7e7e7;color:black;}/*Gray*/
.button5{backgroundcolor:#555555;}/*Black*/
Tentevocmesmo"
Tamanhos boto
Exemplo
.button1{fontsize:10px;}
.button2{fontsize:12px;}
.button3{fontsize:16px;}
.button4{fontsize:20px;}
.button5{fontsize:24px;}
Tentevocmesmo"
2/8
30/12/2015 CSSBotes
Arredondadas Botes
Exemplo
.button1{borderradius:2px;}
.button2{borderradius:4px;}
.button3{borderradius:8px;}
.button4{borderradius:12px;}
.button5{borderradius:50%;}
Tentevocmesmo"
Exemplo
.button1{
backgroundcolor:white;
color:black;
border:2pxsolid#4CAF50;/*Green*/
}
...
3/8
30/12/2015 CSSBotes
Tentevocmesmo"
Hoverable Botes
Exemplo
.button{
webkittransitionduration:0.4s;/*Safari*/
transitionduration:0.4s;
}
.button:hover{
backgroundcolor:#4CAF50;/*Green*/
color:white;
}
...
Tentevocmesmo"
Sombra Botes
4/8
30/12/2015 CSSBotes
BotoSombra Sombraemfoco
Exemplo
.button1{
boxshadow:08px16px0rgba(0,0,0,0.2),06px20px0
rgba(0,0,0,0.19);
}
.button2:hover{
boxshadow:012px16px0rgba(0,0,0,0.24),017px50px0
rgba(0,0,0,0.19);
}
Tentevocmesmo"
Botonormal Botopessoascommobilidadecondicionada
Exemplo
.disabled{
opacity:0.6;
5/8
30/12/2015 CSSBotes
cursor:notallowed;
}
Tentevocmesmo"
Boto Largura
250px
50%
100%
Pordefeito,otamanhodobotodeterminadapeloseuteordetexto(tolarga
comooseucontedo).Usea largura propriedadeparaalteraralarguradeum
boto:
Exemplo
.button1{width:250px;}
.button2{width:50%;}
.button3{width:100%;}
Tentevocmesmo"
Boto Grupos
Boto Boto Boto Boto
6/8
30/12/2015 CSSBotes
Exemplo
.button{
float:left;
}
Tentevocmesmo"
Exemplo
.button{
float:left;
border:1pxsolidgreen
}
Tentevocmesmo"
Animated Buttons
Exemplo
Adicionarumasetaemfoco:
7/8
30/12/2015 CSSBotes
Flutuar
Tentevocmesmo"
Exemplo
Adicionarumefeito"cascata"noclique:
Clique
Tentevocmesmo"
Exemplo
Adicionarumefeitode"pressionado"noclique:
Clique
Tentevocmesmo"
"Anterior Prximocaptulo"
Copyright19992015byRefsnesData.AllRightsReserved.
8/8
30/12/2015 VriasColunasCSS3
Loremipsumdolorsitamet,consectetueradipiscingelit,sednonummydiam
nibheuismodtinciduntutlaoreetdoloremagnaaliquameratvolutpat.Utwisi
enimannciomnimaveniam,Quisnostrudexerciullamcorpertaosuscipit
lobortisNISLutaliquipexeacommodoconsequat.DUISautemveleumiriure
doloremhendreritemvulputatevelitESSEmolestieconsequat,velillumdolore
eufeugiatnullafacilisisnoveroerosetiustoodioaccumsanetquidignissim
blanditPraesentluptatumzzrildelenitaugueDUISdoloretefeugaitnullafacilisi.
NamlibertemporcumSolutanobiseleifendopoconguenihilimperdietdoming
idquodmazimplaceratassumfacerpossim.
Suporte navegador
Osnmerosnatabelaespecificaraprimeiraversodonavegadorquesuporta
totalmenteapropriedade.
Nmerosseguidoporwebkitoumozespecificaraprimeiraversoquetrabalhou
comumprefixo.
Property
1/6
30/12/2015 VriasColunasCSS3
colunadecontagem
columngap
estiloregracoluna
larguradacolunarule
colunadaregracolor
colunadaregra
colunaspan
larguradacoluna
Oexemploaseguirirdividirotextonoelemento<div>em3colunas:
Exemplo
2/6
30/12/2015 VriasColunasCSS3
div{
webkitcolumncount:3;/*Chrome,Safari,Opera*/
mozcolumncount:3;/*Firefox*/
columncount:3;
}
Tentevocmesmo"
Oexemploaseguirespecificaumintervalode40pixelsentreascolunas:
Exemplo
div{
webkitcolumngap:40px;/*Chrome,Safari,Opera*/
mozcolumngap:40px;/*Firefox*/
columngap:40px;
}
Tentevocmesmo"
Exemplo
div{
webkitcolumnrulestyle:solid;/*Chrome,Safari,Opera*/
mozcolumnrulestyle:solid;/*Firefox*/
columnrulestyle:solid;
}
3/6
30/12/2015 VriasColunasCSS3
Tentevocmesmo"
A colunadelarguraregra propriedadeespecificaalarguradaregraentreas
colunas:
Exemplo
div{
webkitcolumnrulewidth:1px;/*Chrome,Safari,Opera*/
mozcolumnrulewidth:1px;/*Firefox*/
columnrulewidth:1px;
}
Tentevocmesmo"
A colunadaregracolor propriedadeespecificaacordaregraentreas
colunas:
Exemplo
div{
webkitcolumnrulecolor:lightblue;/*Chrome,Safari,Opera
*/
mozcolumnrulecolor:lightblue;/*Firefox*/
columnrulecolor:lightblue;
}
Tentevocmesmo"
A colunadaregra propriedadeumatalhoparadefinirtodasascolunas
Governa*propriedadesacima.
Oexemploaseguirdefinealargura,estiloecordaregraentreascolunas:
Exemplo
4/6
30/12/2015 VriasColunasCSS3
div{
webkitcolumnrule:1pxsolidlightblue;/*Chrome,Safari,
Opera*/
mozcolumnrule:1pxsolidlightblue;/*Firefox*/
columnrule:1pxsolidlightblue;
}
Tentevocmesmo"
Oexemploaseguirespecificaqueo<h2>elementodeveabrangerentretodasas
colunas:
Exemplo
h2{
webkitcolumnspan:all;/*Chrome,Safari,Opera*/
columnspan:all;
}
Tentevocmesmo"
Oexemploaseguirespecificaqueosugeriu,alarguraidealparaascolunasdeveser
100px:
5/6
30/12/2015 VriasColunasCSS3
Exemplo
div{
webkitcolumnwidth:100px;/*Chrome,Safari,Opera*/
columnwidth:100px;
}
Tentevocmesmo"
Property Description
columncount Specifiesthenumberofcolumnsanelementshouldbe
dividedinto
columnfill Specifieshowtofillcolumns
columngap Specifiesthegapbetweenthecolumns
columnrule Ashorthandpropertyforsettingallthecolumnrule*
properties
columnrulecolor Specifiesthecoloroftherulebetweencolumns
columnrulestyle Specifiesthestyleoftherulebetweencolumns
columnrulewidth Specifiesthewidthoftherulebetweencolumns
columnspan Specifieshowmanycolumnsanelementshouldspan
across
columnwidth Specifiesasuggested,optimalwidthforthecolumns
columns Ashorthandpropertyforsettingcolumnwidthand
columncount
"Anterior Prximocaptulo"
Copyright19992015byRefsnesData.AllRightsReserved.
6/6
30/12/2015 CSS3InterfacedeUsurio
Nestecaptulo,vocaprendersobreasseguintespropriedadesdainterfacedo
usurio:
redimensionar
delinearoffset
Suporte navegador
Osnmerosnatabelaespecificaraprimeiraversodonavegadorquesuporta
totalmenteapropriedade.
Nmerosseguidoporwebkitoumozespecificaraprimeiraversoquetrabalhou
comumprefixo.
Property
CSS3 redimensionamento
O redimensionamento propriedadeespecificaseounoumelementodeveser
1/4
30/12/2015 CSS3InterfacedeUsurio
redimensionveis
pelousurio.
Esteelementodivredimensionveispelo
usurio(funcionanoChrome,Firefox,Safarie
Opera).
Oexemploaseguirpermitequeousurioredimensionarapenasalarguradeum
elemento<div>:
Exemplo
div{
resize:horizontal;
overflow:auto;
}
Tentevocmesmo"
Oexemploaseguirpermitequeousurioredimensionarapenasaalturadeum
elemento<div>:
Exemplo
div{
resize:vertical;
overflow:auto;
}
Tentevocmesmo"
Oexemploaseguirpermitequeousurioredimensionaraalturaealarguradeum
elemento<div>:
Exemplo
div{
2/4
30/12/2015 CSS3InterfacedeUsurio
resize:both;
overflow:auto;
}
Tentevocmesmo"
Contornosdiferemdasfronteirasdeduasmaneiras:
Umesbooumalinhatraadaemtornodeelementos,foradabordafronteira
Umesboonoocupamespao
Umesquemapodesernorectangular
Estedivtemum
esboo15pxforada
bordafronteira.
Oexemploaseguirusaapropriedadedecompensaodeesbooparaadicionarum
espao15pxentreafronteiraeocontorno:
Exemplo
div{
border:1pxsolidblack;
outline:1pxsolidred;
outlineoffset:15px;
}
Tentevocmesmo"
3/4
30/12/2015 CSS3InterfacedeUsurio
Property Description
boxsizing Allowsyoutoincludethepaddingandborderinan
element'stotalwidthandheight
navdown Specifieswheretonavigatewhenusingthearrow
downnavigationkey
navindex Specifiesthetabbingorderforanelement
navleft Specifieswheretonavigatewhenusingthearrowleft
navigationkey
navright Specifieswheretonavigatewhenusingthearrow
rightnavigationkey
navup Specifieswheretonavigatewhenusingthearrowup
navigationkey
outlineoffset Addsspacebetweenanoutlineandtheedgeorborder
ofanelement
resize Specifieswhetherornotanelementisresizablebythe
user
"Anterior Prximocaptulo"
Copyright19992015byRefsnesData.AllRightsReserved.
4/4
30/12/2015 CSS3BoxDimensionamento
Suporte navegador
Osnmerosnatabelaespecificaraprimeiraversodonavegadorquesuporta
totalmenteapropriedade.
Nmerosseguidoporwebkitoumozespecificaraprimeiraversoquetrabalhou
comumprefixo.
Property
+largura+estofamentoborder=largurarealdeumelemento
altura+estofamento+border=alturarealdeumelemento
Issosignificaque:Quandovocdefiniralargura/alturadeumelemento,oelemento
muitasvezesparecemmaioresdoquevocdefiniu(porquebordadoelementoe
preenchimentosoadicionadosaoespecificadolargura/alturadoelemento).
Ailustraoaseguirmostradoiselementos<div>comamesmalarguraealtura
especificadas:
1/4
30/12/2015 CSS3BoxDimensionamento
Estedivmenor(largura300pxe
altura100px).
Estedivmaior(larguratambm
300pxealtura100px).
Osdoiselementos<div>acimaacabamcomtamanhosdiferentesnoresultado
(porquediv2temumpreenchimentoespecificado):
Exemplo
.div1{
width:300px;
height:100px;
border:1pxsolidblue;
}
.div2{
width:300px;
height:100px;
padding:50px;
border:1pxsolidred;
}
Tentevocmesmo"
Ento,porumlongotempoosdesenvolvedoreswebterespecificadoumvalorde
larguramenordoqueelesqueriam,porquetiveramquesubtrairopreenchimentoe
asfronteiras.
2/4
30/12/2015 CSS3BoxDimensionamento
problema.
Ambososdivssodomesmotamanho
agora!
Hooray!
Aquiestomesmoexemploacima,com caixadimensionamento:Beira
box adicionadoaambososelementos<div>:
Exemplo
.div1{
width:300px;
height:100px;
border:1pxsolidblue;
boxsizing:borderbox;
}
.div2{
width:300px;
height:100px;
padding:50px;
border:1pxsolidred;
boxsizing:borderbox;
}
3/4
30/12/2015 CSS3BoxDimensionamento
Tentevocmesmo"
Comooresultadodeusaro dedimensionamentodecaixa:Beirabox
muitomelhor,muitosdesenvolvedoresqueremtodososelementosemsuaspginas
paratrabalhardestaforma.
Ocdigoabaixoasseguraquetodososelementossodimensionadosdestemodo
maisintuitivo.Muitosnavegadoresj usadimensionamentocaixa:Beira
box paramuitoselementosdeformulrio(masnotodosporissoqueas
entradasetextareasolhardiferenteemwidth:100%).
Aplicandoestaatodososelementosseguroesbio:
Exemplo
*{
boxsizing:borderbox;
}
Tentevocmesmo"
"Anterior Prximocaptulo"
Copyright19992015byRefsnesData.AllRightsReserved.
4/4
30/12/2015 BoxFlexvelCSS3
CSS3 Flexbox
Caixasflexveis,ouflexbox,umnovomododelayoutemCSS3.
Usodeflexboxgarantequeoselementossecomportamdemaneiraprevisvel
quandoolayoutdapginadeveacomodardiferentestamanhosdetelaediferentes
dispositivosdeexibio.
Paramuitasaplicaes,omodelodecaixaflexvelforneceumamelhoriasobreo
modelodeblocosemqueelenousacarrosalegricos,nemmargensdecolapsodo
recipienteflexvelcomasmargensdeseucontedo.
Suporte navegador
Osnmerosnatabelaespecificaraprimeiraversodonavegadorquesuporta
totalmenteorecurso.
Nmerosseguidoporwebkitoumozespecificaraprimeiraversoquetrabalhou
comumprefixo.
Property
Flexboxconsistederecipientesflexveiseitensdeflex.
Dentrodeumrecipienteflexvel,humoumaisitensdeflex.
Nota:Tudoforaumrecipienteflexveledentrodeumitemdeflexoprocessado
comodecostume.FlexboxdefinecomoitensFlexsodefinidosdentrodeum
continerflex.
Flexitenssoposicionadosdentrodeumrecipienteflexvelaolongodeumalinha
flex.Porpadrohapenasumalinhaflexvelporcontinerflex.
Oexemploaseguirmostratrsitensflexveis.Elessoposicionadosporpadro:ao
longodalinhaFlexhorizontal,daesquerdaparaadireita:
Exemplo
<!DOCTYPEhtml>
<html>
<head>
<style>
.flexcontainer{
display:webkitflex;
display:flex;
width:400px;
height:250px;
backgroundcolor:lightgrey;
}
.flexitem{
backgroundcolor:cornflowerblue;
width:100px;
height:100px;
margin:10px;
}
</style>
</head>
<body>
<divclass="flexcontainer">
<divclass="flexitem">flexitem1</div>
2/17
30/12/2015 BoxFlexvelCSS3
<divclass="flexitem">flexitem2</div>
<divclass="flexitem">flexitem3</div>
</div>
</body>
</html>
Tentevocmesmo"
tambmpossvelalteraradirecodalinhadeflex.
Exemplo
body{
direction:rtl;
}
.flexcontainer{
display:webkitflex;
display:flex;
width:400px;
height:250px;
backgroundcolor:lightgrey;
}
.flexitem{
backgroundcolor:cornflowerblue;
width:100px;
height:100px;
margin:10px;
}
Tentevocmesmo"
3/17
30/12/2015 BoxFlexvelCSS3
Direo Flex
O flexdireo propriedadeespecificaadireodositensflexveisdentrodo
recipienteflex.Ovalorpadrode flexdireo fila (daesquerdaparaa
direita,decimaparabaixo).
Osoutrosvaloressoosseguintes:
rowreverse Seomododeescrita(direo)esquerdaparaadireita,os
itensdeflexsercolocadoparaforadireitaparaaesquerda
coluna Seosistemadeescritahorizontal,ositensdeflexsercolocado
paraforaverticalmente
colunareverter Omesmoquecoluna,masemsentidoinverso
Exemplo
.flexcontainer{
display:webkitflex;
display:flex;
webkitflexdirection:rowreverse;
flexdirection:rowreverse;
width:400px;
height:250px;
backgroundcolor:lightgrey;
}
Tentevocmesmo"
Exemplo
.flexcontainer{
display:webkitflex;
display:flex;
webkitflexdirection:column;
flexdirection:column;
width:400px;
4/17
30/12/2015 BoxFlexvelCSS3
height:250px;
backgroundcolor:lightgrey;
}
Tentevocmesmo"
Exemplo
.flexcontainer{
display:webkitflex;
display:flex;
webkitflexdirection:columnreverse;
flexdirection:columnreverse;
width:400px;
height:250px;
backgroundcolor:lightgrey;
}
Tentevocmesmo"
A propriedade justificarcontent
A justificarcontent propriedadealinhahorizontalmenteitensdocontiner
flexvelquandoositensnousetodooespaodisponvelnoeixoprincipal.
Osvalorespossveissoosseguintes:
flexstart Ovalorpadro.Osprodutossoposicionadosnoinciodo
recipiente
Flexend Osprodutossoposicionadosnaextremidadedorecipiente
Centro Osprodutossoposicionadasnocentrodorecipiente
espaoentre Ositenssoposicionadoscomespaoentreaslinhas
espaoaround Ositenssoposicionadoscomespaoantes,entreeaps
aslinhas
5/17
30/12/2015 BoxFlexvelCSS3
Exemplo
.flexcontainer{
display:webkitflex;
display:flex;
webkitjustifycontent:flexend;
justifycontent:flexend;
width:400px;
height:250px;
backgroundcolor:lightgrey;
}
Tentevocmesmo"
Exemplo
.flexcontainer{
display:webkitflex;
display:flex;
webkitjustifycontent:center;
justifycontent:center;
width:400px;
height:250px;
backgroundcolor:lightgrey;
}
Tentevocmesmo"
Exemplo
.flexcontainer{
display:webkitflex;
display:flex;
webkitjustifycontent:spacebetween;
6/17
30/12/2015 BoxFlexvelCSS3
justifycontent:spacebetween;
width:400px;
height:250px;
backgroundcolor:lightgrey;
}
Tentevocmesmo"
Exemplo
.flexcontainer{
display:webkitflex;
display:flex;
webkitjustifycontent:spacearound;
justifycontent:spacearound;
width:400px;
height:250px;
backgroundcolor:lightgrey;
}
Tentevocmesmo"
Os itensalign Propriedade
O alignitens propriedadealinhaverticalmenteitensdocontinerflexvelquando
ositensnousetodooespaodisponvelnoeixotransversal.
Osvalorespossveissoosseguintes:
esticar Ovalorpadro.Ositenssoesticadoparacaberorecipiente
flexstart Ositenssoposicionadonapartesuperiordorecipiente
Flexend Osprodutossoposicionadosnaparteinferiordorecipiente
Centro Osprodutossoposicionadasnocentrodorecipiente
(verticalmente)
basais Ositenssoposicionadosnalinhadebasedorecipiente
7/17
30/12/2015 BoxFlexvelCSS3
Exemplo
.flexcontainer{
display:webkitflex;
display:flex;
webkitalignitems:stretch;
alignitems:stretch;
width:400px;
height:250px;
backgroundcolor:lightgrey;
}
Tentevocmesmo"
Exemplo
.flexcontainer{
display:webkitflex;
display:flex;
webkitalignitems:flexstart;
alignitems:flexstart;
width:400px;
height:250px;
backgroundcolor:lightgrey;
}
Tentevocmesmo"
Exemplo
8/17
30/12/2015 BoxFlexvelCSS3
.flexcontainer{
display:webkitflex;
display:flex;
webkitalignitems:flexend;
alignitems:flexend;
width:400px;
height:250px;
backgroundcolor:lightgrey;
}
Tentevocmesmo"
Exemplo
.flexcontainer{
display:webkitflex;
display:flex;
webkitalignitems:center;
alignitems:center;
width:400px;
height:250px;
backgroundcolor:lightgrey;
}
Tentevocmesmo"
Exemplo
.flexcontainer{
display:webkitflex;
display:flex;
webkitalignitems:baseline;
alignitems:baseline;
width:400px;
9/17
30/12/2015 BoxFlexvelCSS3
height:250px;
backgroundcolor:lightgrey;
}
Tentevocmesmo"
O Flexwrap imvel
O Flexwrap propriedadeespecificaseositensflexveisdeveenvolverouno,se
nohouverespaosuficienteparaelesemumalinhaflex.
Osvalorespossveissoosseguintes:
nowrap Ovalorpadro.Ositensflexveisnosermoldado
embrulhe Ositensflexveisvaiembrulharsenecessrio
wrapreverter Ositensflexveisvaienvolver,senecessrio,emordem
inversa
Exemplo
.flexcontainer{
display:webkitflex;
display:flex;
webkitflexwrap:nowrap;
flexwrap:nowrap;
width:300px;
height:250px;
backgroundcolor:lightgrey;
}
Tentevocmesmo"
Exemplo
10/17
30/12/2015 BoxFlexvelCSS3
.flexcontainer{
display:webkitflex;
display:flex;
webkitflexwrap:wrap;
flexwrap:wrap;
width:300px;
height:250px;
backgroundcolor:lightgrey;
}
Tentevocmesmo"
Exemplo
.flexcontainer{
display:webkitflex;
display:flex;
webkitflexwrap:wrapreverse;
flexwrap:wrapreverse;
width:300px;
height:250px;
backgroundcolor:lightgrey;
}
Tentevocmesmo"
O aligncontent imvel
O aligncontent propriedademodificaocomportamentodo Flexwrap
propriedade.semelhantea alinharitens,masemvezdealinharitens
deflex,elesealinhaflexlinhas.
Osvalorespossveissoosseguintes:
esticar Ovalorpadro.Linhasesticarparaocuparoespaorestante
flexstart Linhassoembaladosemdireoaoinciodorecipienteflexvel
11/17
30/12/2015 BoxFlexvelCSS3
flexend Aslinhassoembaladosemdireoaofinaldorecipienteflexvel
Centro Aslinhassoembaladosemdireoaocentrodorecipienteflexvel
espaoentre Aslinhassodistribudasuniformementenorecipiente
flexvel
espaoaround Aslinhassodistribudasuniformementenorecipiente
flexvel,comespaosmetadedotamanhoemcadaextremidade
Exemplo
.flexcontainer{
display:webkitflex;
display:flex;
webkitflexwrap:wrap;
flexwrap:wrap;
webkitaligncontent:center;
aligncontent:center;
width:300px;
height:300px;
backgroundcolor:lightgrey;
}
Tentevocmesmo"
Exemplo
.flexitem{
backgroundcolor:cornflowerblue;
width:100px;
height:100px;
12/17
30/12/2015 BoxFlexvelCSS3
margin:10px;
}
.first{
webkitorder:1;
order:1;
}
Tentevocmesmo"
Margem
Definindo margin:auto absorverespaoextra.Elepodeserusadopara
empurraritensdeflexemposiesdiferentes.
Exemplo
.flexitem{
backgroundcolor:cornflowerblue;
width:75px;
height:75px;
margin:10px;
}
.flexitem:firstchild{
marginright:auto;
}
Tentevocmesmo"
Centralizao perfeita
Noexemploaseguirvamosresolverumproblemaquasequediariamente:
centralizaoperfeita.
centradaemambososeixos:
Exemplo
.flexitem{
backgroundcolor:cornflowerblue;
width:75px;
height:75px;
margin:auto;
}
Tentevocmesmo"
alinharauto
O alignauto propriedadedeitensdeflexsubstituialignitensdepropriedadedo
recipienteflexvelparaesseitem.Eletemosmesmosvalorespossveiscomoa
alinharitens propriedade.
Oexemploaseguirdefinevaloresdiferentesalignindependentesparacadaitem
Flex:
Exemplo
.flexitem{
backgroundcolor:cornflowerblue;
width:60px;
minheight:100px;
margin:10px;
}
.item1{
webkitalignself:flexstart;
alignself:flexstart;
}
.item2{
webkitalignself:flexend;
alignself:flexend;
}
14/17
30/12/2015 BoxFlexvelCSS3
.item3{
webkitalignself:center;
alignself:center;
}
.item4{
webkitalignself:baseline;
alignself:baseline;
}
.item5{
webkitalignself:stretch;
alignself:stretch;
}
Tentevocmesmo"
flexionar
O caboflexvel propriedadeespecificaocomprimentodoelementoflexvel,em
relaoaorestodoselementosflexveisnointeriordomesmorecipiente.
Noexemploaseguir,oprimeiroitemflexconsomem2/4doespaolivre,eosoutros
doisitensdeflexirconsumirumquartodoespaolivrecadaum:
Exemplo
.flexitem{
backgroundcolor:cornflowerblue;
margin:10px;
}
.item1{
webkitflex:2;
flex:2;
}
.item2{
webkitflex:1;
flex:1;
}
15/17
30/12/2015 BoxFlexvelCSS3
.item3{
webkitflex:1;
flex:1;
}
Tentevocmesmo"
Mais Exemplos
Criarumsiteresponsivocomflexbox
Esteexemplodemonstracomocriarumlayoutdesiteresponsivocomflexbox.
Property Description
display SpecifiesthetypeofboxusedforanHTMLelement
flexdirection Specifiesthedirectionoftheflexibleitemsinsideaflex
container
justifycontent Horizontallyalignstheflexitemswhentheitemsdonot
useallavailablespaceonthemainaxis
alignitems Verticallyalignstheflexitemswhentheitemsdonotuse
allavailablespaceonthecrossaxis
flexwrap Specifieswhethertheflexitemsshouldwrapornot,if
thereisnotenoughroomforthemononeflexline
aligncontent Modifiesthebehavioroftheflexwrapproperty.Itis
similartoalignitems,butinsteadofaligningflexitems,
italignsflexlines
flexflow Ashorthandpropertforflexdirectionandflexwrap
order Specifiestheorderofaflexibleitemrelativetotherest
oftheflexitemsinsidethesamecontainer
alignself Usedonflexitems.Overridesthecontainer'salignitems
16/17
30/12/2015 BoxFlexvelCSS3
property
flex Specifiesthelengthofaflexitem,relativetotherestof
theflexitemsinsidethesamecontainer
"Anterior Prximocaptulo"
Copyright19992015byRefsnesData.AllRightsReserved.
17/17
30/12/2015 CSS3consultasdemdia
Exemplos:Vocpoderiaterumconjuntoderegrasdeestiloparatelasde
computador,umaparaimpressoras,umaparadispositivosdemo,umparaos
dispositivosdotipodeteleviso,eassimpordiante.
Infelizmente,essestiposdemdianuncarecebimuitoapoiopordispositivos,almdo
tipodemdiadeimpresso.
Consultasdemdiapodeserusadoparaverificarmuitascoisas,taiscomo:
larguraealturadajaneladeexibio
larguraealturadodispositivo
orientao(otablet/telefonenomodopaisagemouretrato?)
resoluo
Usandoconsultasdemdiasoumatcnicapopularparaaentregadeumafolhade
estilopersonalizadaparatablets,iPhoneeAndroids.
Suporte navegador
Osnmerosnatabelaespecificaaprimeiraversodonavegadorqueapoia
plenamentearegramedia.
1/4
30/12/2015 CSS3consultasdemdia
Property
@medianot|onlymediatypeand(expressions){
CSSCode;
}
Oresultadodaconsultaserverdadeiraseotipodemdiaespecificadocorresponde
aotipodedispositivoodocumentoestsendoexibidonaetodasasexpressesna
consultademdiasoverdadeiras.Quandoumaconsultademdiaverdade,as
regrasdefolhasdeestiloouestilocorrespondentessoaplicados,seguindoasregras
normaisemcascata.
Amenosquevocuseosoperadoresnoouapenas,otipodemdiaopcionalea
todosos tiposerimplcita.
Voctambmpodeterdiferentesfolhasdeestiloparadiferentesmdias:
<linkrel="stylesheet"media="mediatypeand|not|only(expressions)"
href="print.css">
all Usedforallmediatypedevices
print Usedforprinters
screen Usedforcomputerscreens,tablets,smartphonesetc.
speech Usedforscreenreadersthat"reads"thepageoutloud
2/4
30/12/2015 CSS3consultasdemdia
OexemploaseguiralteraobackgroundcolorparaLightgreenseajaneladeexibio
de480pixelsdelarguraoumaislarga(seajaneladeexibiomenordoque480
pixels,obackgroundcolorserrosa):
Exemplo
@mediascreenand(minwidth:480px){
body{
backgroundcolor:lightgreen;
}
}
Tentevocmesmo"
Oexemploaseguirmostraummenuqueirflutuaresquerdadapgina,seajanela
deexibiode480pixelsdelarguraoumaislarga(seajaneladeexibiomenor
doque480pixels,omenuestaremcimadocontedo):
Exemplo
@mediascreenand(minwidth:480px){
#leftsidebar{width:200px;float:left;}
#main{marginleft:216px;}
}
Tentevocmesmo"
CSS3media Referncia
Paraumavisocompletadetodosostiposdemdiae/expressescaractersticas,
porfavor,vejaomediaregraemnossarefernciaCSS.
3/4
30/12/2015 CSS3consultasdemdia
"Anterior Prximocaptulo"
Copyright19992015byRefsnesData.AllRightsReserved.
4/4
30/12/2015 CSS3consultasdemdiaExemplos
Vamoscomearcomumalistadenomesquefuncionamcomolinksdeemail.O
HTML:
Exemplo 1
<!DOCTYPEhtml>
<html>
<head>
<style>
ul{
liststyletype:none;
}
ullia{
color:green;
textdecoration:none;
padding:3px;
display:block;
}
</style>
</head>
<body>
<ul>
<li><adataemail="johndoe@example.com"
href="mailto:johndoe@example.com">JohnDoe</a></li>
<li><adataemail="marymoe@example.com"
href="mailto:marymoe@example.com">MaryMoe</a></li>
<li><adataemail="amandapanda@example.com"
1/4
30/12/2015 CSS3consultasdemdiaExemplos
href="mailto:amandapanda@example.com">AmandaPanda</a></li>
</ul>
</body>
</html>
Tentevocmesmo"
Exemplo 2
@mediascreenand(maxwidth:699px)and(minwidth:520px){
ullia{
paddingleft:30px;
background:url(emailicon.png)leftcenternorepeat;
}
}
Tentevocmesmo"
2/4
30/12/2015 CSS3consultasdemdiaExemplos
Exemplo 3
@mediascreenand(maxwidth:1000px)and(minwidth:700px){
ullia:before{
content:"Email:";
fontstyle:italic;
color:#666666;
}
}
Tentevocmesmo"
Exemplo 4
@mediascreenand(minwidth:1001px){
ullia:after{
content:"("attr(dataemail)")";
fontsize:12px;
fontstyle:italic;
color:#666666;
}
}
Tentevocmesmo"
3/4
30/12/2015 CSS3consultasdemdiaExemplos
Aqui,notemosparaescreverumblocodeconsultademdiaadicionais,podemos
simplesmenteanexarumaconsultademdiaadicionalaonossojexistenteusando
umavrgula(issoircomportarsecomoumoperadorOR):
Exemplo 5
@mediascreenand(maxwidth:699px)and(minwidth:520px),(min
width:1151px){
ullia{
paddingleft:30px;
background:url(emailicon.png)leftcenternorepeat;
}
}
Tentevocmesmo"
Mais Exemplos
UsealistadelinksdeemailemumabarralateralemumapginadaWeb
Esteexemplocolocaalistadelinksdeemailnabarralateralesquerdadeuma
pginaweb.
"Anterior Prximocaptulo"
Copyright19992015byRefsnesData.AllRightsReserved.
4/4