Core CSS3

Rachel Andrew
Rachel AndrewWriter, speaker, co-founder of Perch CMS. Google Developer Expert for Web Technologies at A List Apart
hello.
Rachel Andrew

    @rachelandrew

   rachelandrew.co.uk
   edgeofmyseat.com
     grabaperch.com
CSS 3
CSS3 is the next
 version of CSS
CSS3 is Modular
Some CSS3 modules
 are more complete
     than others
W3C Maturity Levels
Working Draft
Candidate Recommendation
Proposed Recommendation
W3C Recommendation
http://www.w3.org/2005/10/Process-20051014/tr#maturity-levels
CSS3 is supported by
      browsers

 Some browsers and some (parts of) modules.
Vendor-speci c
  extensions

 Implementing early stage CSS3
border-radius
border-radius
.box {
   -moz-border-radius: 10px;
   -webkit-border-radius: 10px;
   border-radius: 10px;
 }
In defence of vendor-
  speci c extensions
Using CSS3
Selectors module

   W3C Proposed Recommendation
 http://www.w3.org/TR/css3-selectors/
The problem with
    CSS2 selectors
                     Not precise
                   Led to “classitis”
If we can’t access mark-up it is hard to target things
CSS3 Selectors
           “Common sense” new selectors
target elements more precisely without adding classes
rst-child

target an element when it is the first child of a parent
                     element
rst-child
rst-child

div#wrapper p:first-child {

 
 font-size: 1.5em;
}
rst-child
last-child

target an element when it is the last child of a parent
                     element
last-child
last-child

ul#navigation li:last-child {

 
 border-bottom: none;
}
last-child
nth-child

select multiple elements according to their position in
                   the document tree
nth-child
nth-child

tr:nth-child(odd) td {

 
 background-color: #f0e9c5;
}
nth-child
nth-child

tr:nth-child(2n+1) td {

 
 background-color: #f0e9c5;
}


   http://reference.sitepoint.com/css/understandingnthchildexpressions
Adjacent Sibling

div#wrapper h1 + p {

 font-size: 1.5em;
}
Adjacent Sibling
Attribute Selectors

form input[type="text"] {

}

form input[type="submit"] {

}
Attribute Selectors
Attribute Selectors
label[for="fContact"] {
    
 float: none;
    
 width: auto;
}

a[href ^="mailto:"] {

 
 padding-right: 20px;

 
 background-image:url(email.png);

 
 background-repeat: no-repeat;

 
 background-position: right center;
}
Browser
Support
Browser Support
Does it
matter?
Yes, it
matters.
JavaScript

Plug the holes in browser support using JavaScript.
jQuery: rst-child
div#wrapper p:first-child,
div#wrapper p.first {

 
 font-size: 1.5em;
}




<script src="http://code.jquery.com/jquery-latest.js"></
script>
<script>
  $(document).ready(function(){

 $("div#wrapper p:first-child").addClass("first");
  });
</script>
jQuery: last-child
ul#navigation li:last-child, ul#navigation li.last {

 
 border-bottom: none;
}




<script src="http://code.jquery.com/jquery-latest.js"></
script>
<script>
  $(document).ready(function(){

 $("ul#navigation li:last-child").addClass("last");
  });
</script>
jQuery: nth-child
tr:nth-child(odd) td, td.odd {

 background-color: #f0e9c5;
}




<script src="http://code.jquery.com/jquery-latest.js"></
script>
<script>
  $(document).ready(function(){

 $("tr:nth-child(odd) td").addClass("odd");
  });
</script>
Scripts that “ x IE”

 http://www.keithclark.co.uk/labs/ie-css3/
          http://ecsstender.org
Color module

         Working Draft
http://www.w3.org/TR/css3-color/
opacity

specify the opacity of an element
opacity
opacity
ul#gallery li {

 
 opacity: 0.4;
}

ul#gallery li:hover {

 
 opacity: 1;
}
RGBA

specify the opacity of a colour with ‘alpha’
RGBA
RGBA

div#feature .caption {
    background-color: rgba(255,255,255,0.5);
}
24ways.org
Browser
Support?
Fonts module

         Working Draft
http://www.w3.org/TR/css3-fonts/
@font-face

using a font other than one installed on your user’s
                     computer
@font-face
@font-face {
  
 ont-family: KaffeesatzBold;
  f
  
 rc: url(YanoneKaffeesatz-
  s
Bold.ttf);
}

h1 {

 font-family: KaffeesatzBold, sans-
serif;

 font-weight: normal;
}
Fonts with Font
   Squirrel

  http://www.fontsquirrel.com
Font Squirrel
Font Squirrel
@font-face {

 font-family: 'YanoneKaffeesatzBold';

 
 src: url('yanonekaffeesatz-bold-webfont.eot');

 
 src: local('☺'), url('yanonekaffeesatz-bold-
webfont.woff') format('woff'), url('yanonekaffeesatz-
bold-webfont.ttf') format('truetype'),
url('yanonekaffeesatz-bold-webfont.svg#webfontUcEp3Pt5')
format('svg');

 font-weight: normal;

 font-style: normal;
}
Hosted font services
     http://www.typekit.com
      http://fontdeck.com/
rachelandrew.co.uk
Backgrounds &
Borders module

   W3C Candidate Recommendation
http://www.w3.org/TR/css3-background/
multiple
         backgrounds

Apply more than one background image to an element
backgrounds
blockquote {

 
 background: url(quote-
left.gif) top left no-repeat,

 
 url(quote-right.gif) bottom
right no-repeat;

 }
backgrounds
border-radius

 Yes! CSS rounded corners
border-radius
.box1   {

 
     background-color: #a18c83;

 
     border: 3px solid #6d4d6b;

 
     -moz-border-radius: 15px;

 
     -webkit-border-radius: 15px;
         border-radius: 15px;

   
   color: #fff;

   
   padding: 10px;

   
   margin: 0 0 20px 0;

   }


   .box2 {

   
 border: 5px solid #6d4d6b;

   
 -moz-border-radius-topleft: 50px;

   
 -webkit-border-top-left-radius: 50px;
       border-top-left-radius: 50px;

   
 padding: 10px 5px 5px 20px;

   }
border-radius
Browser
Support
Media Queries

    W3C Candidate Recommendation
http://www.w3.org/TR/css3-mediaqueries/
Media Queries
target browser characteristics, for example screen
           resolution, width and height
Media Queries
div#wrapper {

   width: 780px;

   margin-left: auto;

   margin-right: auto;
}

div#header {

   background-image: url(media-queries-browser.jpg);

   height: 349px;

   position: relative;
}

#content {

   float: left;

   width: 540px;
}

#navigation {

   float:right;

   width: 200px;
}
Media Queries
Media Queries
@media screen and (max-device-width: 480px) {

   
    div#wrapper {

   
    
   width: 400px;

   
    }


   
    div#header {

   
    
   background-image: url(media-queries-phone.jpg);

   
    
   height: 93px;

   
    
   position: relative;

   
    }

   

   
    div#header h1 {

   
    
   font-size: 140%;

   
    }

   

   
    #content {

   
    
   float: none;

   
    
   width: 100%;

   
    }


   
    #navigation {

   
    
   float:none;

   
    
   width: auto;

   
    }

   }
Media Queries
Media Queries
<link media="screen and (max-
device-width: 480px)"
href="small.css" type= "text/
css" rel="stylesheet" />
2010.dconstruct.org
2010.dconstruct.org
Thank you.

    Slides and resources: http://wp.me/PorPc-9d
Photo credit for Media Queries example: http://www.flickr.com/photos/dominicspics/4625808875/
            Font for web fonts example: http://www.yanone.de/typedesign/kaffeesatz/
1 of 78

Recommended

Introduction to CSS3 by
Introduction to CSS3Introduction to CSS3
Introduction to CSS3hstryk
830 views14 slides
CSSプリプロセッサの取扱説明書 by
CSSプリプロセッサの取扱説明書CSSプリプロセッサの取扱説明書
CSSプリプロセッサの取扱説明書拓樹 谷
2.4K views114 slides
Client Side Performance In Web Applications Resources by
Client Side Performance In Web Applications   ResourcesClient Side Performance In Web Applications   Resources
Client Side Performance In Web Applications Resourcesvladungureanu
320 views4 slides
Tukulam by
TukulamTukulam
TukulamTipspo Tips
289 views63 slides
HTML5 and CSS3 – exploring mobile possibilities - Frontend Conference Zürich by
HTML5 and CSS3 – exploring mobile possibilities - Frontend Conference ZürichHTML5 and CSS3 – exploring mobile possibilities - Frontend Conference Zürich
HTML5 and CSS3 – exploring mobile possibilities - Frontend Conference ZürichRobert Nyman
5.7K views87 slides
Theme04 by
Theme04Theme04
Theme04Atleta De Taekwondo
450 views5 slides

More Related Content

What's hot

前端开发理论热点面对面:从怎么看,到怎么做? by
前端开发理论热点面对面:从怎么看,到怎么做?前端开发理论热点面对面:从怎么看,到怎么做?
前端开发理论热点面对面:从怎么看,到怎么做?Kejun Zhang
28.2K views89 slides
Theme02 by
Theme02Theme02
Theme02Atleta De Taekwondo
496 views6 slides
Tmx9 by
Tmx9Tmx9
Tmx9Lukas Mickosz
235 views8 slides
Css & css3 by
Css & css3Css & css3
Css & css3isha
122 views15 slides
Curso CSS3 com Sass e Compass - Aula 01 - Introducão by
Curso CSS3 com Sass e Compass - Aula 01 - IntroducãoCurso CSS3 com Sass e Compass - Aula 01 - Introducão
Curso CSS3 com Sass e Compass - Aula 01 - IntroducãoLoiane Groner
727 views87 slides
Html standards presentation by
Html standards presentationHtml standards presentation
Html standards presentationTiago Cardoso
799 views51 slides

What's hot(7)

前端开发理论热点面对面:从怎么看,到怎么做? by Kejun Zhang
前端开发理论热点面对面:从怎么看,到怎么做?前端开发理论热点面对面:从怎么看,到怎么做?
前端开发理论热点面对面:从怎么看,到怎么做?
Kejun Zhang28.2K views
Css & css3 by isha
Css & css3Css & css3
Css & css3
isha 122 views
Curso CSS3 com Sass e Compass - Aula 01 - Introducão by Loiane Groner
Curso CSS3 com Sass e Compass - Aula 01 - IntroducãoCurso CSS3 com Sass e Compass - Aula 01 - Introducão
Curso CSS3 com Sass e Compass - Aula 01 - Introducão
Loiane Groner727 views
Html standards presentation by Tiago Cardoso
Html standards presentationHtml standards presentation
Html standards presentation
Tiago Cardoso799 views
SASS, Compass, Gulp, Greensock by Marco Pinheiro
SASS, Compass, Gulp, GreensockSASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, Greensock
Marco Pinheiro1.3K views

Viewers also liked

Presentación Multimedia - HTML5 by
Presentación Multimedia - HTML5Presentación Multimedia - HTML5
Presentación Multimedia - HTML5Viviana Trujillo
664 views19 slides
ตัวอย่าง Workshop basic html5 and css3 จากไอทีจีเนียส by
ตัวอย่าง Workshop basic html5 and css3 จากไอทีจีเนียสตัวอย่าง Workshop basic html5 and css3 จากไอทีจีเนียส
ตัวอย่าง Workshop basic html5 and css3 จากไอทีจีเนียสSamit Koyom
780 views14 slides
Techdays 2012 - Développement Web Mobile avec Microsoft by
Techdays 2012 - Développement Web Mobile avec MicrosoftTechdays 2012 - Développement Web Mobile avec Microsoft
Techdays 2012 - Développement Web Mobile avec Microsoftwyggio
1.4K views40 slides
Microsoft TechDays - CSS3 Presentation by
Microsoft TechDays - CSS3 PresentationMicrosoft TechDays - CSS3 Presentation
Microsoft TechDays - CSS3 PresentationRachel Andrew
2K views109 slides
Css floats by
Css floatsCss floats
Css floatsWebtech Learning
1.1K views8 slides
Structure Web Content by
Structure Web ContentStructure Web Content
Structure Web ContentNicole Ryan
3.7K views30 slides

Viewers also liked(20)

ตัวอย่าง Workshop basic html5 and css3 จากไอทีจีเนียส by Samit Koyom
ตัวอย่าง Workshop basic html5 and css3 จากไอทีจีเนียสตัวอย่าง Workshop basic html5 and css3 จากไอทีจีเนียส
ตัวอย่าง Workshop basic html5 and css3 จากไอทีจีเนียส
Samit Koyom780 views
Techdays 2012 - Développement Web Mobile avec Microsoft by wyggio
Techdays 2012 - Développement Web Mobile avec MicrosoftTechdays 2012 - Développement Web Mobile avec Microsoft
Techdays 2012 - Développement Web Mobile avec Microsoft
wyggio1.4K views
Microsoft TechDays - CSS3 Presentation by Rachel Andrew
Microsoft TechDays - CSS3 PresentationMicrosoft TechDays - CSS3 Presentation
Microsoft TechDays - CSS3 Presentation
Rachel Andrew2K views
Structure Web Content by Nicole Ryan
Structure Web ContentStructure Web Content
Structure Web Content
Nicole Ryan3.7K views
Laying Out Elements with CSS by Nicole Ryan
Laying Out Elements with CSSLaying Out Elements with CSS
Laying Out Elements with CSS
Nicole Ryan2.9K views
Getting Started with CSS by Nicole Ryan
Getting Started with CSSGetting Started with CSS
Getting Started with CSS
Nicole Ryan2.9K views
Pt 175 rc-web by juanjosero
Pt 175 rc-webPt 175 rc-web
Pt 175 rc-web
juanjosero295 views
Tabela inss 2011 by Joaoce2011
Tabela inss 2011Tabela inss 2011
Tabela inss 2011
Joaoce2011766 views
Portal Educativo Xunta by pcuestacefore
Portal Educativo XuntaPortal Educativo Xunta
Portal Educativo Xunta
pcuestacefore2.4K views
Marcas más Populares México Febrero2012 by IAB México
Marcas más Populares México   Febrero2012Marcas más Populares México   Febrero2012
Marcas más Populares México Febrero2012
IAB México396 views
Macul2011 text by elizkeren
Macul2011 textMacul2011 text
Macul2011 text
elizkeren1K views

Similar to Core CSS3

Introduction to Responsive Web Design by
Introduction to Responsive Web DesignIntroduction to Responsive Web Design
Introduction to Responsive Web DesignClarissa Peterson
23.5K views152 slides
From PSD to WordPress Theme: Bringing designs to life by
From PSD to WordPress Theme: Bringing designs to lifeFrom PSD to WordPress Theme: Bringing designs to life
From PSD to WordPress Theme: Bringing designs to lifeDerek Christensen
2K views68 slides
Managing responsive websites with css preprocessors. by
Managing responsive websites with css preprocessors. Managing responsive websites with css preprocessors.
Managing responsive websites with css preprocessors. The University of Akron
1.1K views29 slides
Prototyping w/HTML5 and CSS3 by
Prototyping w/HTML5 and CSS3Prototyping w/HTML5 and CSS3
Prototyping w/HTML5 and CSS3Todd Zaki Warfel
5.1K views51 slides
css.ppt by
css.pptcss.ppt
css.pptDakshPratapSingh1
4 views66 slides
css.ppt by
css.pptcss.ppt
css.pptSana903754
32 views66 slides

Similar to Core CSS3(20)

Introduction to Responsive Web Design by Clarissa Peterson
Introduction to Responsive Web DesignIntroduction to Responsive Web Design
Introduction to Responsive Web Design
Clarissa Peterson23.5K views
From PSD to WordPress Theme: Bringing designs to life by Derek Christensen
From PSD to WordPress Theme: Bringing designs to lifeFrom PSD to WordPress Theme: Bringing designs to life
From PSD to WordPress Theme: Bringing designs to life
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5 by Sadaaki HIRAI
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5
Sadaaki HIRAI4.6K views
GDI Seattle Intermediate HTML and CSS Class 1 by Heather Rock
GDI Seattle Intermediate HTML and CSS Class 1GDI Seattle Intermediate HTML and CSS Class 1
GDI Seattle Intermediate HTML and CSS Class 1
Heather Rock786 views
HTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile Event by Robert Nyman
HTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile EventHTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile Event
HTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile Event
Robert Nyman15.1K views
Web Development for Mobile: GTUG Talk at Google by Estelle Weyl
Web Development for Mobile: GTUG Talk at GoogleWeb Development for Mobile: GTUG Talk at Google
Web Development for Mobile: GTUG Talk at Google
Estelle Weyl4.7K views
Module 4 Minuteman Lexington Web Design Daniel Downs by Daniel Downs
Module 4 Minuteman Lexington Web Design Daniel DownsModule 4 Minuteman Lexington Web Design Daniel Downs
Module 4 Minuteman Lexington Web Design Daniel Downs
Daniel Downs525 views
Modifying your themes design - Learning CSS - Atlanta WordPress users group by Evan Mullins
Modifying your themes design - Learning CSS - Atlanta WordPress users groupModifying your themes design - Learning CSS - Atlanta WordPress users group
Modifying your themes design - Learning CSS - Atlanta WordPress users group
Evan Mullins2.7K views
CSS3: Are you experienced? by Denise Jacobs
CSS3: Are you experienced?CSS3: Are you experienced?
CSS3: Are you experienced?
Denise Jacobs18.4K views
Palestra pré processadores CSS by Just Digital
Palestra pré processadores CSSPalestra pré processadores CSS
Palestra pré processadores CSS
Just Digital1.3K views

More from Rachel Andrew

All Day Hey! Unlocking The Power of CSS Grid Layout by
All Day Hey! Unlocking The Power of CSS Grid LayoutAll Day Hey! Unlocking The Power of CSS Grid Layout
All Day Hey! Unlocking The Power of CSS Grid LayoutRachel Andrew
2.2K views113 slides
SmashingConf SF: Unlocking the Power of CSS Grid Layout by
SmashingConf SF: Unlocking the Power of CSS Grid LayoutSmashingConf SF: Unlocking the Power of CSS Grid Layout
SmashingConf SF: Unlocking the Power of CSS Grid LayoutRachel Andrew
2.3K views113 slides
Unlocking the Power of CSS Grid Layout by
Unlocking the Power of CSS Grid LayoutUnlocking the Power of CSS Grid Layout
Unlocking the Power of CSS Grid LayoutRachel Andrew
2K views113 slides
The Creative New World of CSS by
The Creative New World of CSSThe Creative New World of CSS
The Creative New World of CSSRachel Andrew
2K views144 slides
Into the Weeds of CSS Layout by
Into the Weeds of CSS LayoutInto the Weeds of CSS Layout
Into the Weeds of CSS LayoutRachel Andrew
1.5K views93 slides
Solving Layout Problems with CSS Grid & Friends - DevFest17 by
Solving Layout Problems with CSS Grid & Friends - DevFest17Solving Layout Problems with CSS Grid & Friends - DevFest17
Solving Layout Problems with CSS Grid & Friends - DevFest17Rachel Andrew
2.1K views96 slides

More from Rachel Andrew(20)

All Day Hey! Unlocking The Power of CSS Grid Layout by Rachel Andrew
All Day Hey! Unlocking The Power of CSS Grid LayoutAll Day Hey! Unlocking The Power of CSS Grid Layout
All Day Hey! Unlocking The Power of CSS Grid Layout
Rachel Andrew2.2K views
SmashingConf SF: Unlocking the Power of CSS Grid Layout by Rachel Andrew
SmashingConf SF: Unlocking the Power of CSS Grid LayoutSmashingConf SF: Unlocking the Power of CSS Grid Layout
SmashingConf SF: Unlocking the Power of CSS Grid Layout
Rachel Andrew2.3K views
Unlocking the Power of CSS Grid Layout by Rachel Andrew
Unlocking the Power of CSS Grid LayoutUnlocking the Power of CSS Grid Layout
Unlocking the Power of CSS Grid Layout
Rachel Andrew2K views
The Creative New World of CSS by Rachel Andrew
The Creative New World of CSSThe Creative New World of CSS
The Creative New World of CSS
Rachel Andrew2K views
Into the Weeds of CSS Layout by Rachel Andrew
Into the Weeds of CSS LayoutInto the Weeds of CSS Layout
Into the Weeds of CSS Layout
Rachel Andrew1.5K views
Solving Layout Problems with CSS Grid & Friends - DevFest17 by Rachel Andrew
Solving Layout Problems with CSS Grid & Friends - DevFest17Solving Layout Problems with CSS Grid & Friends - DevFest17
Solving Layout Problems with CSS Grid & Friends - DevFest17
Rachel Andrew2.1K views
View Source London: Solving Layout Problems with CSS Grid & Friends by Rachel Andrew
View Source London: Solving Layout Problems with CSS Grid & FriendsView Source London: Solving Layout Problems with CSS Grid & Friends
View Source London: Solving Layout Problems with CSS Grid & Friends
Rachel Andrew1K views
DevFest Nantes - Start Using CSS Grid Layout today by Rachel Andrew
DevFest Nantes - Start Using CSS Grid Layout todayDevFest Nantes - Start Using CSS Grid Layout today
DevFest Nantes - Start Using CSS Grid Layout today
Rachel Andrew1.1K views
Start Using CSS Grid Layout Today - RuhrJS by Rachel Andrew
Start Using CSS Grid Layout Today - RuhrJSStart Using CSS Grid Layout Today - RuhrJS
Start Using CSS Grid Layout Today - RuhrJS
Rachel Andrew990 views
404.ie: Solving Layout Problems with CSS Grid & Friends by Rachel Andrew
404.ie: Solving Layout Problems with CSS Grid & Friends404.ie: Solving Layout Problems with CSS Grid & Friends
404.ie: Solving Layout Problems with CSS Grid & Friends
Rachel Andrew909 views
Solving Layout Problems with CSS Grid & Friends - WEBU17 by Rachel Andrew
Solving Layout Problems with CSS Grid & Friends - WEBU17Solving Layout Problems with CSS Grid & Friends - WEBU17
Solving Layout Problems with CSS Grid & Friends - WEBU17
Rachel Andrew902 views
Laying out the future with grid & flexbox - Smashing Conf Freiburg by Rachel Andrew
Laying out the future with grid & flexbox - Smashing Conf FreiburgLaying out the future with grid & flexbox - Smashing Conf Freiburg
Laying out the future with grid & flexbox - Smashing Conf Freiburg
Rachel Andrew2.4K views
Solving Layout Problems with CSS Grid & Friends - NordicJS by Rachel Andrew
Solving Layout Problems with CSS Grid & Friends - NordicJSSolving Layout Problems with CSS Grid & Friends - NordicJS
Solving Layout Problems with CSS Grid & Friends - NordicJS
Rachel Andrew2.7K views
Google Developers Experts Summit 2017 - CSS Layout by Rachel Andrew
Google Developers Experts Summit 2017 - CSS Layout Google Developers Experts Summit 2017 - CSS Layout
Google Developers Experts Summit 2017 - CSS Layout
Rachel Andrew1.4K views
Web Summer Camp Keynote by Rachel Andrew
Web Summer Camp KeynoteWeb Summer Camp Keynote
Web Summer Camp Keynote
Rachel Andrew1.9K views
New CSS Layout Meets the Real World by Rachel Andrew
New CSS Layout Meets the Real WorldNew CSS Layout Meets the Real World
New CSS Layout Meets the Real World
Rachel Andrew864 views
An Event Apart DC - New CSS Layout meets the Real World by Rachel Andrew
An Event Apart DC - New CSS Layout meets the Real WorldAn Event Apart DC - New CSS Layout meets the Real World
An Event Apart DC - New CSS Layout meets the Real World
Rachel Andrew408 views
Perch, Patterns and Old Browsers by Rachel Andrew
Perch, Patterns and Old BrowsersPerch, Patterns and Old Browsers
Perch, Patterns and Old Browsers
Rachel Andrew1.8K views
Evergreen websites for Evergreen browsers by Rachel Andrew
Evergreen websites for Evergreen browsersEvergreen websites for Evergreen browsers
Evergreen websites for Evergreen browsers
Rachel Andrew1.5K views

Recently uploaded

20231123_Camunda Meetup Vienna.pdf by
20231123_Camunda Meetup Vienna.pdf20231123_Camunda Meetup Vienna.pdf
20231123_Camunda Meetup Vienna.pdfPhactum Softwareentwicklung GmbH
23 views73 slides
Black and White Modern Science Presentation.pptx by
Black and White Modern Science Presentation.pptxBlack and White Modern Science Presentation.pptx
Black and White Modern Science Presentation.pptxmaryamkhalid2916
14 views21 slides
ChatGPT and AI for Web Developers by
ChatGPT and AI for Web DevelopersChatGPT and AI for Web Developers
ChatGPT and AI for Web DevelopersMaximiliano Firtman
174 views82 slides
.conf Go 2023 - Data analysis as a routine by
.conf Go 2023 - Data analysis as a routine.conf Go 2023 - Data analysis as a routine
.conf Go 2023 - Data analysis as a routineSplunk
90 views12 slides
Understanding GenAI/LLM and What is Google Offering - Felix Goh by
Understanding GenAI/LLM and What is Google Offering - Felix GohUnderstanding GenAI/LLM and What is Google Offering - Felix Goh
Understanding GenAI/LLM and What is Google Offering - Felix GohNUS-ISS
39 views33 slides

Recently uploaded(20)

Black and White Modern Science Presentation.pptx by maryamkhalid2916
Black and White Modern Science Presentation.pptxBlack and White Modern Science Presentation.pptx
Black and White Modern Science Presentation.pptx
maryamkhalid291614 views
.conf Go 2023 - Data analysis as a routine by Splunk
.conf Go 2023 - Data analysis as a routine.conf Go 2023 - Data analysis as a routine
.conf Go 2023 - Data analysis as a routine
Splunk90 views
Understanding GenAI/LLM and What is Google Offering - Felix Goh by NUS-ISS
Understanding GenAI/LLM and What is Google Offering - Felix GohUnderstanding GenAI/LLM and What is Google Offering - Felix Goh
Understanding GenAI/LLM and What is Google Offering - Felix Goh
NUS-ISS39 views
Attacking IoT Devices from a Web Perspective - Linux Day by Simone Onofri
Attacking IoT Devices from a Web Perspective - Linux Day Attacking IoT Devices from a Web Perspective - Linux Day
Attacking IoT Devices from a Web Perspective - Linux Day
Simone Onofri15 views
[2023] Putting the R! in R&D.pdf by Eleanor McHugh
[2023] Putting the R! in R&D.pdf[2023] Putting the R! in R&D.pdf
[2023] Putting the R! in R&D.pdf
Eleanor McHugh38 views
Emerging & Future Technology - How to Prepare for the Next 10 Years of Radica... by NUS-ISS
Emerging & Future Technology - How to Prepare for the Next 10 Years of Radica...Emerging & Future Technology - How to Prepare for the Next 10 Years of Radica...
Emerging & Future Technology - How to Prepare for the Next 10 Years of Radica...
NUS-ISS15 views
Web Dev - 1 PPT.pdf by gdsczhcet
Web Dev - 1 PPT.pdfWeb Dev - 1 PPT.pdf
Web Dev - 1 PPT.pdf
gdsczhcet52 views
Voice Logger - Telephony Integration Solution at Aegis by Nirmal Sharma
Voice Logger - Telephony Integration Solution at AegisVoice Logger - Telephony Integration Solution at Aegis
Voice Logger - Telephony Integration Solution at Aegis
Nirmal Sharma17 views
PharoJS - Zürich Smalltalk Group Meetup November 2023 by Noury Bouraqadi
PharoJS - Zürich Smalltalk Group Meetup November 2023PharoJS - Zürich Smalltalk Group Meetup November 2023
PharoJS - Zürich Smalltalk Group Meetup November 2023
Noury Bouraqadi113 views
Perth MeetUp November 2023 by Michael Price
Perth MeetUp November 2023 Perth MeetUp November 2023
Perth MeetUp November 2023
Michael Price12 views
SAP Automation Using Bar Code and FIORI.pdf by Virendra Rai, PMP
SAP Automation Using Bar Code and FIORI.pdfSAP Automation Using Bar Code and FIORI.pdf
SAP Automation Using Bar Code and FIORI.pdf
Digital Product-Centric Enterprise and Enterprise Architecture - Tan Eng Tsze by NUS-ISS
Digital Product-Centric Enterprise and Enterprise Architecture - Tan Eng TszeDigital Product-Centric Enterprise and Enterprise Architecture - Tan Eng Tsze
Digital Product-Centric Enterprise and Enterprise Architecture - Tan Eng Tsze
NUS-ISS19 views
Spesifikasi Lengkap ASUS Vivobook Go 14 by Dot Semarang
Spesifikasi Lengkap ASUS Vivobook Go 14Spesifikasi Lengkap ASUS Vivobook Go 14
Spesifikasi Lengkap ASUS Vivobook Go 14
Dot Semarang35 views

Core CSS3

Editor's Notes

  1. I&amp;#x2019;m Rachel Andrew. You can find me on Twitter @rachelandrew and the links here are to my personal and business sites if you want to know who I am. The important thing is that I&amp;#x2019;m a front and back-end web developer and spend my days actually using the stuff I&amp;#x2019;m going to be talking about today on commercial projects for real clients. So I tend to take a pretty practical approach to it and feature the things I feel are useful right now.
  2. This session is Core CSS3 - so in the next 40 minutes or so we&amp;#x2019;ll have a look at CSS3 with an emphasis on things we can use right now. Don&amp;#x2019;t worry about taking notes or copying down code - I&amp;#x2019;ll give you a link at the end of the presentation where you can download slides, example code, and any links for examples. So what is CSS3?
  3. Fairly obvious - CSS3 is the next version of CSS.
  4. Earlier versions of CSS were a single monolithic spec. CSS3 is different - it is broken down into modules.
  5. Modules are at different levels of completeness and slower, more involved modules then don&amp;#x2019;t hold up other parts of the spec.
  6. Working Draft (WD) A Working Draft is a document that W3C has published for review by the community, including W3C Members, the public, and other technical organizations. Candidate Recommendation (CR) - gather implementation experience Proposed Recommendation (PR) - sent to the W3C Advisory Committee for final endorsement. W3C Recommendation (REC) -specification or set of guidelines that, after extensive consensus-building, has received the endorsement of W3C Members and the Director. W3C recommends the wide deployment of its Recommendations.
  7. Browsers have been implementing parts of the CSS3 spec for a long time. Firefox, Opera, Safari, Chrome etc. all offer support for many different parts of the spec.
  8. Vendor specific extensions are one way that browser manufacturers started to implement CSS3 at a very early stage of some modules.
  9. We&amp;#x2019;ll be looking at this in detail later but border-radius (which gives us rounded corners in pure CSS) is one place where browsers implemented support with their own extensions.
  10. The 1st line is how Mozilla implemented this in Firefox when the module was at a very early stage, the 2nd is the webkit extension for Safari and other webkit browsers (including Chrome). Safari 5 - just out - has added support for the standard border-radius. The last line here is the actual CSS3 border radius property. If using a Vendor specific extension always add the actual CSS3 declaration as well. For example when IE9 comes out it will support border-radius, if you omit it now from your CSS then IE9 won&amp;#x2019;t show the rounded corners even though it would be able to.
  11. a W3C approved way to add extensions Usually added at an early stage of module development If the module changes the browser doesn&amp;#x2019;t need to change their implementation thus breaking older code. Use carefully and keep an eye on the actual spec and correct way to do things.
  12. I&amp;#x2019;m now going to take a look at some practical examples of CSS3 - things that I&amp;#x2019;m currently using in real sites.
  13. Selectors module
  14. In CSS 1 and 2 we had selectors that let us target things such as html elements - h1, h2, paragraphs, divs and also classes and ids. Often have to add classes just for the CSS - for example a class on the last item on a list Annoying when we can access the mark-up, doesn&amp;#x2019;t help separate presentation from content &amp; structure Sometimes we can&amp;#x2019;t access the mark-up - generated by a CMS we can&amp;#x2019;t change etc. and then we end up having to lose bits of a design because we can&amp;#x2019;t do them without adding classes.
  15. CSS3 selectors will just make our lives so much easier - both for front and back-end developers.
  16. first-child actually appears in the 2.1 spec however lack of browser support in older versions of IE means it doesn&amp;#x2019;t get a lot of use. It&amp;#x2019;s a nice easy way to start looking at more advanced selectors however.
  17. We have a set of paragraphs -these are inside a div with an id of wrapper. With CSS2 we would need to put a class on the first para in order to style it differently.
  18. As this screenshot shows - the CSS we used means we can target that first paragraph and make the text larger without needing to add anything to the mark-up.
  19. Introduced in CSS3
  20. An example where last-child might be useful is when styling list navigation. The li elements have a bottom border but we don&amp;#x2019;t want to put that on the last element.
  21. As you can see this removes the border just from the last li in that list - once again we don&amp;#x2019;t need to add any additional elements to our mark-up.
  22. We have a table here and the designer has requested that we colour every other table row to aid readability. This is a common request and usually means the developer has to put a class on the odd rows.
  23. Here are our odd rows all coloured as requested, with no additional mark-up.
  24. nth-child can take arguments using a multiplier in addition to odd and even keywords. Using the multiplier 2n+1 would be the same as using the keyword odd. These multipliers get a bit complicated and I would suggest having a look at the listed Sitepoint resource to get your head around how they work as they can be a very powerful way to taregt elements in your mark-up.
  25. The selectors we have looked at are all &amp;#x201C;structural pseudo-classes&amp;#x201D; they look a bit like the other pseudo-class selectors you may be familiar with - the ones we use for the different states of a link - link, visited, hover and active. Time limits me from looking at too many selectors today but another group of selectors that are very useful are known as combinators. We have things like an adjacent sibling combinator&amp;#x2019; selecting an element that is next to another element that shares the same parent. So the p that comes straight after an h1 for example.
  26. This rule would make the first paragraph directly after an h1 larger in this example.
  27. Attribute selectors were also part of CSS2.1 however lack of browser support has meant they are not much used. However as they are also part of CSS3 and very useful in our aim of not cluttering mark-up with classes we&amp;#x2019;ll have a quick look at them. Attribute selectors let you get at an element based on it&amp;#x2019;s attribute. An obvious use for these is in forms. If you just target input you get text fields, submit buttons and checkboxes etc. This usually means we stick classes on all the input elements to distinguish them. Attribute selectors let you look at the type attribute of the input element and style appropriately.
  28. There are two other things I have used attribute selectors for in this example. The labels have been styled floated left and given a width - which I don&amp;#x2019;t want to do with the checkbox label. I also wanted to display and email icon next to the email us text.
  29. So I&amp;#x2019;m using the for attribute on the label to check for the label of that field and setting it to float none and width auto. To get the email link we use the second declaration - ^= shows we want to match things in the href that begin with mailto
  30. So before we get too excited about this - what about the thorny issue of browser support? If you know a bit about CSS3 and aren&amp;#x2019;t using it right now it is probably because of the requirement to support more browsers than just those that have support for these selectors already.
  31. as you can see things look great if we look at Firefox, Safari, Chrome and Opera ... not so stunning when it comes to Internet Explorer. Even the most recent release of IE8. A couple of selectors we looked at that we part of CSS2.1 (attribute and first-child are supported by IE7 and 8) Things look up when it comes to IE9 which promises to support a lot of CSS3 however what can we do now?
  32. The first thing to check is &amp;#x201C;does it matter&amp;#x201D; that Internet Explorer sees something a bit different. In a very few cases you might feel happy to just fall back to allowing IE to not have striped tables, larger initial paragraphs etc.
  33. For most of us though, our clients would expect the site to look pretty much the same in IE8 as in Firefox so what can we do?
  34. Particularly where selectors are concerned, you can very easily add support using JavaScript.
  35. This is an example of how you can use jQuery to add support for first-child. Add a class to your rule for p.first then select the first-child using jQuery (which supports the CSS3 selectors) and add the class. You could just add the CSS directly using jQuery but then you have to remember to update the rules in the JavaScript as well as in the CSS so I feel this is a bit neater.
  36. Here is the same technique as used for last-child
  37. and nth-child. JQuery makes this very easy but you could do the same using any library you are already using on your site.
  38. IE-CSS3.js - selectors only, needs a library included as well ecsstender - several extensions for different modules if not already using javascript these can be really useful. If using js I&amp;#x2019;d usually add a fixSelectors function into my UI js file and do them there. I&amp;#x2019;d urge caution in putting these scripts in place at the beginning of a build - rmemeber some users may have an old browser and no javascript, make sure the experience is ok for them before adding js to the mix.
  39. Color module - properties that allow authors to specify the foreground color and opacity of an element
  40. Opacity effects the entire element and it&amp;#x2019;s contents.
  41. The boxes have been given an opacity value, we are also using the hover pseudo-class on the list item to change the opacity on hover.
  42. Should be noted that opacity effects everything in the li including the text.
  43. The color module introduces RGBA
  44. I needed to get a photo of my cat in here somewhere... the caption on this photo has a semi-transparent background which is implemented using RGBA. I didn&amp;#x2019;t want to use opacity as that would have made the text opaque as well.
  45. The 0.5 is an opacity value on the background colour. 0 would be transparent 1 would be fully opaque - a solid colour.
  46. See an example of RGBA being used extensively on the design for 24ways.
  47. Neither opacity or RGBa are supported by IE up to version 8. If using RGBA you should specify a color using rgb before the rgba line in your CSS in order to provide a fully opaque version - without this no colour will be used. You can fake some of this using JavaScript depending on the effect you are going for. The good news is that IE9 will have support.
  48. Fonts module
  49. One thing that web designers have longed for is the ability to be able to specify particular fonts and know that users will be able to view the site in them. @font-face enables the importing of a font that you have uploaded to your web server - then that font can be used in your font stacks just like any standard font.
  50. In theory this should work like this. The @font-face rule points to the font file with a familiar url construct. You can then use it. In the real world however things are not so simple... we have two problems, different browsers and operating systems and the licensing of fonts. Many fonts you will find are not licensed in such a way that you can upload them to your web server, presuming you have a font that is able to be licensed. You can do the following:
  51. Upload your fonts and Font Squirrel will create a package of fonts that will work across all major browsers.
  52. You will end up with a fairly terrifying looking @font-face declaration but it will contain font files that work well cross browser.
  53. Using a hosted font from typekit
  54. Background and borders module
  55. So here is something that should make a lot of people happy. The CSS3 backgrounds module allows for applying multiple backgrounds to a single element.
  56. so on this blockquote element I can add image quote marks as a background at the top left and bottom right of the element without needing to add an extra element.
  57. ...which gives us a result like this. I&amp;#x2019;m sure you can think of lots of uses for multiple background images.
  58. So it is probably against the law to do a CSS3 presentation without mentioning rounded corners so here they are. The backgrounds and borders module includes the spec for adding rounded corners to an element.
  59. As of Firefox 3.6 FF supports multiple backgrounds as do recent versions of Safari, Opera and Chrome. Rounded corners are supported by all these browsers as well. IE9 will have support for these - until then you can effect support using JavaScript if required.
  60. I want to wrap up this introduction to the useful now bits of CSS3 with a quick look at media queries. The great thing about media queries is that the place where they are most useful - we already have good support.
  61. Media queries let you target browser characteristics such as screen resolution and provide alternate styles. If you have ever created a print stylesheet the concept of creating a whole new stylesheet or overwriting some existing styles should be familiar to you. Where this is very useful today is if you want to create a version of your site for the iPhone or other devices that support media queries. A device running an up to date Webkit, Opera or Mozilla based browser should have support.
  62. Here is the code that creates a two column layout.
  63. It looks something like this in Safari or other browsers. I have decided that for iPhone and other small device users I would like the big image at the top to be smaller to reduce scrolling and the layout to drop to one column with the main content at the top.
  64. so this is the code that detects the screen width of the device and resizes accordingly. The important bit is that which I have highlighted in yellow. So here we are in our main stylesheet or in style tags at the head of the document in my example just to keep it all in one place. This lot comes after the main screen CSS so overwrites them if the user has a device with a max-device-width of 480pixels.
  65. So we get something like this.
  66. I could also have 2 stylesheets and link the appropriate one using this link syntax. In practice I&amp;#x2019;d probably go for this approach as it seems neater to me to have the different styles in a separate stylesheet and I like the maintainability of it. If you only have a few changes to make though you could do them inline as previously demonstrated.
  67. example site using media queries in browser
  68. example site on iPhone. Even if you feel that a lot of CSS3 isn&amp;#x2019;t possible for you to use for your sites and clients right now, I&amp;#x2019;d really encourage you to have a look at media queries. With just a little bit of CSS you can have customised views of your site for small screen devices - a special iPhone version just thrown in for free as far as your clients are concerned. Definitely worth trying out.
  69. So that about wraps it up. (Check time for questions). Later on today or this evening - wifi permitting - I should get my slides, some resources, and example files online at the above URL - I&amp;#x2019;ll also post to my blog once they are up at rachelandrew.co.uk.