SlideShare una empresa de Scribd logo
1 de 56
CSS3: the new style
     council
   Chris Mills, Opera Software




            Slides available on http://slideshare.net/chrisdavidmills
http://www.flickr.com/photos/attackcat/5172855379/
Who the hell am I?
‣ Opera open standards evangelist and tech writer
‣ Telling the world about open standards & Opera
‣ Improving web education
‣ Moaning
‣ Drinking beer & saving the world before morning
‣ Drumming in a heavy metal band
CSS3!



 http://www.flickr.com/photos/burningmax/4956554644/
What is CSS3?
‣ A series of new modules
‣ Add extra functionality on top of CSS2.1
‣ Lets us do things more quickly and easily
Sounds good!
‣ Less time spent in Photoshop
‣ Less time spent with JavaScript
‣ Less time spent maintaining sites
‣ More time spent in the pub
Modular = good
‣ Browser vendors can work on one module at a
  time
‣ Less worry and pressure about supporting the
  entire spec
When should I use it?
I’d argue “now”
‣ Most browsers support most of this stuff now
‣ Most of it degrades gracefully
‣ And you can work around problems
‣ Depends on what your client needs
‣ By “identical”, how similar do you mean??
Try to argue the case...
...”identical in every browser” is outdated
‣ Especially with mobile phones, iPad, tablets...
‣ And IE6 is a decade old now
‣ Surely providing an acceptable experience in
   each browser is, well, acceptable?
‣ Then you can spend more less time on hacking
Modernizr
Using modernizr
<html
class="no‐js">










+
<script
src="modernizr‐1.6.min.js"></script>

















=
<html
class="js
no‐flexbox
canvas
canvastext
no‐
webgl
no‐touch
geolocation
postmessage

websqldatabase
no‐indexeddb
hashchange
no‐history

no‐draganddrop
no‐websockets
rgba
hsla
multiplebgs

backgroundsize
borderimage
borderradius
boxshadow

textshadow
opacity
no‐cssanimations
...
>
Using modernizr
.no‐cssanimations
#animated‐menu
{


...
}
Drop shadows
text‐shadow:
black
3px
3px
5px;

text‐shadow:
0
0
4px
white,













0
‐5px
4px
#ffff33,













2px
‐10px
6px
#ffdd33,













‐2px
‐15px
11px
#ff8800,













2px
‐25px
18px
#ff2200,
Drop shadows
box‐shadow:
4px
4px
5px
black;
‐webkit‐box‐shadow:
4px
4px
5px
black;
Drop shadows
Inset:
box‐shadow:
inset
‐4px
‐4px
10px
black;

Spread:
box‐shadow:
4px
4px
5px
6px
black;
Opacity
background‐color:
rgb(204,204,204);
border:
1px
solid
black;
opacity:
0.6;
RGB(a)
background‐color:
rgba(204,204,204,0.6);
HSL(a)
#p1
{
background‐color:
hsla(0,100%,50%,1);
}

#p2
{
background‐color:
hsla(0,100%,60%,1);
}

#p3
{
background‐color:
hsla(0,100%,70%,1);
}

#p4
{
background‐color:
hsla(0,100%,80%,1);
}
border-radius
Finally — web 2.0 is easy!
border‐radius:
10px;

border‐radius:
0px
0px
10px
0px;
Transitions
Offer animation-like abilities
‣ Set a default state for the element
‣ Choose property to transition, and duration
‣ Then set state to transition to
Transition default state
#links
a,
#links
a:link
{


color:
black;


font‐size:
1.2em;


padding:
0.5em;


display:
block;


text‐decoration:
none;


background‐color:
rgb(255,255,255);


transition‐property:
background‐color;


transition‐duration:
1s;
Transitioned state
#links
a:hover,
#links
a:active

{


background‐color:
rgb(150,150,150);
}
Transitions: easing
Controlling the pattern of acceleration/
deceleration, for a more natural feel
transition‐timing‐function:
ease‐in;
transition‐timing‐function:
ease‐out;
transition‐timing‐function:
ease‐in‐out;
transition‐timing‐function:
ease‐out‐in;
transition‐timing‐function:
linear;
Transitions: delay
Add a delay before the transition starts
transition‐delay:
2s;
Multiple transitions
Each with their own start time

transition‐property:
background‐color,
width;

transition‐duration:
1s,
3s;
Transition shorthand
Order of properties: property, duration, timing-
function, delay.

transition:
all
1s
ease‐in
2s;
2D Transforms
Transform element size, position, rotation, skew,
etc.
Transform origin
What point does the transform occur around?
transform‐origin:
3em
bottom;
transform‐origin:
center;
transform‐origin:
20%
50%;
Moving elements
Along X and Y elements

transform:
translateX(50px);
transform:
translateY(100px);
transform:
translate(50px,
100px);
Resizing elements
By a set scale factor

transform:
scale(1.1);
Skewing elements
Squishy distortion!

transform:
skew(7deg,
3deg);
Rotating elements
Around the origin point

transform:
rotate(3deg);
Combining transforms
Doing multiple things in one declaration

transform:
scale(2)
rotate(10deg)
translateX(30px);
Combining transitions with
transforms
This is where it starts to get really fun!

li
a
.menubutton
{


transition:
0.5s
all;


transform‐origin:
center;


transform:
scale(1);


opacity:
0.5;
}
Combining transitions with
transforms
li
a
.menubutton:hover
{


opacity:
1;


transform:
scale(1.1);
}
Web fonts
‣ Download custom fonts along with your web
  pages
‣ Solve our typography nightmares
Include the font
@font‐face
{


font‐family:
“My
font”;


src:
url(http://www.myweb.com/fonts/myfont.ttf);


format(“truetype”);
}
Then use it in your page as
normal
p
{


font‐family:
“My
font”;
}
Web fonts issues
‣ Licensing
‣ Large downloads
‣ Cross browser troubles: multiple formats needed
Browser format support
‣ Opera 10.6+: OpenType, TrueType, SVG
‣ IE9 + : EOT, OpenType, WOFF
‣ Firefox 3.6+ : OpenType, TrueType, WOFF
‣ Chrome 6+ : OpenType, TrueType, SVG
‣ Safari 5+ : OpenType, TrueType
Font squirrel rocks
This is what you need!
@font‐face
{


font‐family:
'ActionIsRegular';


src:
url('actionis‐webfont.eot?')
format('eot'),







url('actionis‐webfont.woff')
format('woff'),







url('actionis‐webfont.ttf')

format('truetype'),







url('actionis‐webfont.svg#webfontg3JxrxOm')

format('svg');


font‐weight:
normal;


font‐style:
normal;
}
Media queries
Media types on steroids
‣ Apply CSS depending on device/browser
  attributes
‣ Very useful for optimizing layouts for different
  devices
‣ (http://people.opera.com/danield/css3/vangogh/
  index.php)
‣ http://mediaqueri.es
Device attributes
‣ Browser width/height
‣ Device width/height
‣ Resolution
‣ Aspect ratio
‣ Monochromacity
‣ etc.
A sample media query
@media
all
and
(max‐width:
480px),
all
and
(max‐
device‐width:
480px)
{


...
}
CSS3 Selectors
[attr*str]        :nth‐last‐of‐type(n)
[attr^str]        :nth‐last‐child(n)
[attr~str]        :only‐child
:first‐child      :only‐of‐type
:last‐child       :checked
:first‐of‐type    :valid
:last‐of‐type     :invalid
:nth‐child(n)     :enabled       :target
:nth‐of‐type(n)   :disabled      And
more!
CSS3 Selector examples
article>p:nth‐of‐type(1)
article>p:first‐of‐type
div[id*=page]:target
p:first‐child
input[type=text]:valid
tr:nth‐child(2n+1)
tr:nth‐child(odd)
:target is cool!
<li><a
href="#page1"><p
class="menubutton">Page
1</
p></a></li>
<li><a
href="#page2"><p
class="menubutton">Page
2</
p></a></li>

<div
id="page1"></div>
<div
id="page2"></div>
:target is cool!
div[id*=page]
{


position:
absolute;


width:
440px;
height:
480px;


padding:
20px
30px
20px
30px;


opacity:
0;


transition:
1s
all;
}
:target is cool!
div[id*=page]:target
{


opacity:
1;


z‐index:
5;
}
object-fit, object-position
img
{


object‐fit:
none;


//
also
takes
contain,
cover
and
fill
values


object‐position:
25%
50%;


//
just
like
background‐position
}
Multiple backgrounds
header
{


background:
url(icon.gif)
top
left
no‐repeat,














url(pattern.jpg)
repeat,














url(center‐spine.png)
top
center














repeat‐y;


}
CSS keyframe animation
@‐webkit‐keyframes
heartmove
{


0%
{




padding‐left:
0px;
padding‐top:
0px;


}



50%
{




padding‐left:
4px;
padding‐top:
4px;


}


100%
{




padding‐left:
0px;
padding‐top:
0px;


}
}
CSS keyframe animation
.heartmove
{


‐webkit‐animation‐name:
heartmove;


‐webkit‐animation‐duration:
0.5s;


‐webkit‐animation‐iteration‐count:
infinite;
}
And there’s more!
‣ 3D transforms
‣ multi-col
‣ Flex box
‣ Animation
‣ Gradients
‣ Reflections...
‣ ..and it goes on...
Thanks for listening!
‣ cmills@opera.com
‣ @chrisdavidmills
‣ http://dev.opera.com
‣ http://www.opera.com/wsc
‣ http://interactwithwebstandards.com

Más contenido relacionado

Destacado (6)

Introduction to whats new in css3
Introduction to whats new in css3Introduction to whats new in css3
Introduction to whats new in css3
 
Css3
Css3Css3
Css3
 
CSS3: stay tuned for style
CSS3: stay tuned for styleCSS3: stay tuned for style
CSS3: stay tuned for style
 
Presentation about html5 css3
Presentation about html5 css3Presentation about html5 css3
Presentation about html5 css3
 
Introduction to HTML5 & CSS3
Introduction to HTML5 & CSS3Introduction to HTML5 & CSS3
Introduction to HTML5 & CSS3
 
Node.JS and WebSockets with Faye
Node.JS and WebSockets with FayeNode.JS and WebSockets with Faye
Node.JS and WebSockets with Faye
 

Similar a CSS3: the new style council

Building Responsive Websites and Apps with Drupal
Building Responsive Websites and Apps with DrupalBuilding Responsive Websites and Apps with Drupal
Building Responsive Websites and Apps with Drupal
Four Kitchens
 
Modern Browser Support
Modern Browser SupportModern Browser Support
Modern Browser Support
Mark Meeker
 
East of Toronto .NET Usergroup - Put the 5 in HTML
East of Toronto .NET Usergroup - Put the 5 in HTMLEast of Toronto .NET Usergroup - Put the 5 in HTML
East of Toronto .NET Usergroup - Put the 5 in HTML
Frédéric Harper
 
Designing with CSS3 Effectively & Efficiently
Designing with CSS3 Effectively & EfficientlyDesigning with CSS3 Effectively & Efficiently
Designing with CSS3 Effectively & Efficiently
Zoe Gillenwater
 
HTML5 Dev Conf - Sass, Compass & the new Webdev tools
HTML5 Dev Conf - Sass, Compass &  the new Webdev toolsHTML5 Dev Conf - Sass, Compass &  the new Webdev tools
HTML5 Dev Conf - Sass, Compass & the new Webdev tools
Dirk Ginader
 
FITC - 2012-04-23 - Responsive Web Design
FITC - 2012-04-23 - Responsive Web DesignFITC - 2012-04-23 - Responsive Web Design
FITC - 2012-04-23 - Responsive Web Design
Frédéric Harper
 

Similar a CSS3: the new style council (20)

Building Responsive Websites and Apps with Drupal
Building Responsive Websites and Apps with DrupalBuilding Responsive Websites and Apps with Drupal
Building Responsive Websites and Apps with Drupal
 
Echo HTML5
Echo HTML5Echo HTML5
Echo HTML5
 
Optimizing content for the "mobile web"
Optimizing content for the "mobile web"Optimizing content for the "mobile web"
Optimizing content for the "mobile web"
 
Modern Browser Support
Modern Browser SupportModern Browser Support
Modern Browser Support
 
Flourish2011
Flourish2011Flourish2011
Flourish2011
 
The web standards gentleman: a matter of (evolving) standards)
The web standards gentleman: a matter of (evolving) standards)The web standards gentleman: a matter of (evolving) standards)
The web standards gentleman: a matter of (evolving) standards)
 
Bruce Lawson Opera Indonesia
Bruce Lawson Opera IndonesiaBruce Lawson Opera Indonesia
Bruce Lawson Opera Indonesia
 
Responsive Web Design: the secret sauce - JavaScript Open Day Montreal - 2015...
Responsive Web Design: the secret sauce - JavaScript Open Day Montreal - 2015...Responsive Web Design: the secret sauce - JavaScript Open Day Montreal - 2015...
Responsive Web Design: the secret sauce - JavaScript Open Day Montreal - 2015...
 
East of Toronto .NET Usergroup - Put the 5 in HTML
East of Toronto .NET Usergroup - Put the 5 in HTMLEast of Toronto .NET Usergroup - Put the 5 in HTML
East of Toronto .NET Usergroup - Put the 5 in HTML
 
Enjoying the full stack - Frontend 2010
Enjoying the full stack - Frontend 2010Enjoying the full stack - Frontend 2010
Enjoying the full stack - Frontend 2010
 
Designing with CSS3 Effectively & Efficiently
Designing with CSS3 Effectively & EfficientlyDesigning with CSS3 Effectively & Efficiently
Designing with CSS3 Effectively & Efficiently
 
Real solutions, no tricks
Real solutions, no tricksReal solutions, no tricks
Real solutions, no tricks
 
[heweb11] CSS3 Makeover
[heweb11] CSS3 Makeover[heweb11] CSS3 Makeover
[heweb11] CSS3 Makeover
 
Ease into HTML5 and CSS3
Ease into HTML5 and CSS3Ease into HTML5 and CSS3
Ease into HTML5 and CSS3
 
RWD in the Wild
RWD in the WildRWD in the Wild
RWD in the Wild
 
HTML5 Dev Conf - Sass, Compass & the new Webdev tools
HTML5 Dev Conf - Sass, Compass &  the new Webdev toolsHTML5 Dev Conf - Sass, Compass &  the new Webdev tools
HTML5 Dev Conf - Sass, Compass & the new Webdev tools
 
An Introduction to Responsive Design
An Introduction to Responsive DesignAn Introduction to Responsive Design
An Introduction to Responsive Design
 
Html 5 mobile - nitty gritty
Html 5 mobile - nitty grittyHtml 5 mobile - nitty gritty
Html 5 mobile - nitty gritty
 
CSS for Mobile
CSS for MobileCSS for Mobile
CSS for Mobile
 
FITC - 2012-04-23 - Responsive Web Design
FITC - 2012-04-23 - Responsive Web DesignFITC - 2012-04-23 - Responsive Web Design
FITC - 2012-04-23 - Responsive Web Design
 

Más de Chris Mills

Empowering the "mobile web"
Empowering the "mobile web"Empowering the "mobile web"
Empowering the "mobile web"
Chris Mills
 
Documentation and publishing
Documentation and publishingDocumentation and publishing
Documentation and publishing
Chris Mills
 

Más de Chris Mills (20)

More efficient, usable web
More efficient, usable webMore efficient, usable web
More efficient, usable web
 
Feedback handling, community wrangling, panhandlin’
Feedback handling, community wrangling, panhandlin’Feedback handling, community wrangling, panhandlin’
Feedback handling, community wrangling, panhandlin’
 
APIs for modern web apps
APIs for modern web appsAPIs for modern web apps
APIs for modern web apps
 
APIs, now and in the future
APIs, now and in the futureAPIs, now and in the future
APIs, now and in the future
 
Guerrilla education
Guerrilla educationGuerrilla education
Guerrilla education
 
Web versus Native: round 1!
Web versus Native: round 1!Web versus Native: round 1!
Web versus Native: round 1!
 
BrazilJS MDN
BrazilJS MDNBrazilJS MDN
BrazilJS MDN
 
Empowering the "mobile web"
Empowering the "mobile web"Empowering the "mobile web"
Empowering the "mobile web"
 
Documentation and publishing
Documentation and publishingDocumentation and publishing
Documentation and publishing
 
MDN is easy!
MDN is easy!MDN is easy!
MDN is easy!
 
Getting rid of images with CSS
Getting rid of images with CSSGetting rid of images with CSS
Getting rid of images with CSS
 
Future layouts
Future layoutsFuture layouts
Future layouts
 
Laying out the future
Laying out the futureLaying out the future
Laying out the future
 
Accessibility doesn't exist
Accessibility doesn't existAccessibility doesn't exist
Accessibility doesn't exist
 
Responsive web design standards?
Responsive web design standards?Responsive web design standards?
Responsive web design standards?
 
Adapt! Media queries and viewport
Adapt! Media queries and viewportAdapt! Media queries and viewport
Adapt! Media queries and viewport
 
Adapt and respond: keeping responsive into the future
Adapt and respond: keeping responsive into the futureAdapt and respond: keeping responsive into the future
Adapt and respond: keeping responsive into the future
 
HTML5 and CSS3: does now really mean now?
HTML5 and CSS3: does now really mean now?HTML5 and CSS3: does now really mean now?
HTML5 and CSS3: does now really mean now?
 
The W3C and the web design ecosystem
The W3C and the web design ecosystemThe W3C and the web design ecosystem
The W3C and the web design ecosystem
 
HTML5 Pearson preso
HTML5 Pearson presoHTML5 Pearson preso
HTML5 Pearson preso
 

Último

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Último (20)

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

CSS3: the new style council

Notas del editor

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n