How to use CSS3 2011 4 CSS3 CSS3 CSS3 P.012 -webkit- -webkit- -moz- -webkit- -webkit- -o- -ms- HTML XHTML TIPS 010
W3C CSS3 TIPS CSS3 CSS2.1 CSS3 CSS current work http://www.w3.org/stle/css/current-work.en.html CSS2.1 Chapter 1 Selectors Snta Media Queries Paged Media Chapter 2 Basic Bo Model Fleible Bo Laout Grid Laout Multi-column Laout Positioning - Chapter 3 Color Backgrounds and Borders Image Values and Replaced Content Chapter 4 Fonts Tet Line Laout Writing Modes Rub Lists Generated and Replaced Content Tables - Chapter 5 2D Transformations 2D 3D Transformations 3D Transitions Animations Chapter 6 Basic User Interface W3C Working Draft ( 草案 ) Last Call Working Draft ( 最終草案 ) W3C Editor s Draft Candidate Recommendation ( 建議候補 ) Proposed Recommendation ( 建議案 ) Recommendation ( 建議 ) 011
051 Chapter 2 margin: auto 0 -webkit- -webkit- -moz- -webkit- -webkit- -o- -ms- displa table inline-table table-caption Basic Bo Model CSS bo model P.050 margin SAMPLE A <> <> margin: ; 40 SAMPLE B margin 60p 80p 80p 60p <h1> <p> P.055 margin: ; margin: 60p 80p; {border: solid 2p orange; background-color: moccasin; tet-align: center; margin: ;} <>HAM SANDWICHES</> margin {border: solid 2p orange; background-color: moccasin; tet-align: center; margin: 60p 80p;} 2
2 Chapter 2 margin-top: margin-*: * top right bottom left SAMPLE C bo width P.057 bo bo 300 bo 300 bo margin-left margin-right auto bo bo auto auto 300p auto {border: solid 2p orange; background-color: moccasin; tet-align: center; width: 300p; margin-left: auto; margin-right: auto;} <>HAM SANDWICHES</> SAMPLE D bo block bo P.047 <h2> <p> block bo block bo 40 20 60 40 h2 {border: solid 2p orange; background-color: moccasin; tet-align: center; margin-top: ; margin-bottom: ;} p {border: solid 2p limegreen; background-color: palegreen; margin-top: ; margin-bottom: ;} <h2>ham SANDWICHES</h2> <p></p> 052
053 margin block bo float P.061 position P.095 absolute <p> float: left; 60 <p> float: left; 60p SAMPLE E block bo <> <h2> <p> <> block bo p {border: solid 2p limegreen; background-color: palegreen; margin-top: ; margin-bottom: ; float: left;} 2 bo <> <> block bo {background-color: lavender; margin-top: 10p; margin-bottom: 10p;} <> 10 <h2> h2 {border: solid 2p orange; tet-align: center; margin-top: ; margin-bottom: ;} <p> <> bo 40 20 p {border: solid 2p limegreen; margin-top: ; margin-bottom: ;} 10p <> <h2>ham SANDWICHES</h2> <p></p> </> 10p
4 Chapter 4 -webkit- -webkit- -moz- -webkit- -webkit- -o- -ms- font-famil: Meiro Hiragino Kaku Gothic Pro serif sans-serif cursive fantas monospace - Fonts font-famil Windows Mac OS X font-famil: 1, 2, serif serif sans-serif sans serif serif sans serif monospace cursive fantas Windows 7 Internet Eplorer 9 SAMPLE A <h2> Verdana sans serif Verdana Windows Mac OS X font-famil <p> Gothic Windows Meiro Mac OS X Hiragino Kaku Gothic Pro sans-serif ' " font-famil h2 {font-famil: Verdana, sans-serif;} p {font-famil: 'Meiro', 'Hiragino Kaku Gothic Pro', sans-serif;} <h2>ham SANDWICHES</h2> <p> </p> 160
161 font-famil SAMPLE B Windows Mac OS X Win Mac Meiro - SAMPLE A Mac OS X Safari Chrome Hiragino Font MS P Gothic - Hiragino Kaku Gothic Pro - MS P - Hiragino Mincho Pro - MS Gothic - Osaka-mono - Gothic ios Android Gothic SAMPLE C Windows Mac OS X ios Android 3 font-famil 1 serif Android Droid Sans Droid Serif Droid Sans Mono sans-serif serif monospace ios Android Android SS... sans-serif Droid Sans 1... Arial Win Mac ios Android Arial SS Arial Black - SS Comic Sans MS - SS Courier M Courier New M Georgia S Impact - SS Times New Roman S Tahoma - SS Trebuchet MS SS Verdana SS Amedican Tpewriter - SS AppleGothic - SS Helvetica 1 SS Helvetica Neue - SS Marker Felt - SS Zapfino - SS S... serif Droid Serif M... Droid Sans Mono 4
4 Chapter 4 -webkit- -webkit- -moz- -webkit- -webkit- -o- -ms- @font-face { font-famil: src: font-stle: font-weight: font-stretch: unicode-range: }...... url() url() format() local()... normal italic oblique P.165 CSS3... normal bold 100 200 300 400 500 600 700 800 900 P.165... ultra-condensed etra-condensed condensed semi-condensed normal semi-epanded epanded etra-epanded ultra-epanded P.166... Unicode code point P.168 - - - Fonts CSS2.1 CSS3 @font-face @fontface WOFF Web Open Font Format WOFF TrueTpe Open Tpe Embedded OpenTpe EOT IE IE 4 @font-face EOT IE 8 SVG Font XML base Vendor SVG ios4.1 WOFF TrueTpe.ttf OpenTpe.otf Embedded OpenTpe.eot SVG Font.svg Firefo - - Safari - - Chrome - Opera 1 - IE 2 2 2 - ios - 3 3 - Android - 4 4 - - 1 Opera 11.10 2 IE 9 3 ios4.2 4 Android 2.2 IE9 TrueTpe OpenTpe P.169 162
163 @font-face SAMPLE A @font-face font-famil src WOFF Quicksand P.169 font-famil Quicksandsrc url(~)format(~) URL @font-face font-famil src descriptor @font-face font-famil font-famil descriptor inline font-famil: Quicksand SVG Font SVG Font URL # ID ID SVG <font>id qsbook SAMPLE B @font-face src descriptor WOFF TrueTpe OpenTpe WOFF TrueTpe Firefo Chrome Opera IE9 WOFF Safari ios4.2 Android2.2 TrueTpe Quicksand_Book.woff @font-face { font-famil: 'Quicksand'; src: url('quicksand_book.woff') format('woff'); } < stle="font-famil:quicksand">ham Sandwiches</> WOFF TrueTpe OpenTpe Embedded Open Tpe SVG Font format() @font-face { font-famil: 'Quicksand'; src: url('quicksand_book.svg#qsbook') format('svg'); } SVG Font src descriptor <?ml version="1.0" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http:// www.w3.org/graphics/svg/1.1/dtd/svg11.dtd" > <font id="qsbook" horiz-adv-="880" > SVG Quicksand_Book.svg src: 1, 2, @font-face src @font-face { font-famil: 'Quicksand'; src: url('quicksand_book.woff') format('woff'), } format() woff truetpe opentpe embedded-opentpe svg url('quicksand_book.ttf') format('truetpe'); WOFF TrueTpe 4
5 Chapter 5 2D -webkit- -webkit- -moz- -webkit- -webkit- -o- -ms- transform: CSS3 translate() translatex() translatey() scale() scalex() scaley() rotate() skew() skewx() skewy() matri() none none block inline 2D Transformations transform 2D 3D 3D P.262 2D rotate() translate() translatex() translatey() scale() scalex() scaley() skew() skewx() skewy() matri() none matri SAMPLE A transform transform Local transform Local (0,0) (0,0) <> Local <>HAM SANDWICHES</> transform rotate(10deg) <> <> Local 10 Local <> bo transform transform-origin 50% 50% transform-origin P.260 (0,0) 10 (0,0) {-webkit-transform: rotate(10deg); -moz-transform: rotate(10deg); -o-transform: rotate(10deg); -ms-transform: rotate(10deg);} <>HAM SANDWICHES</> 256
transform 0.5 2 scale(0.5, 2) (0,0) (0,0) 10 Local Local 0.5 2 {-webkit-transform: rotate(10deg) scale(0.5, 2); -moz-transform: rotate(10deg) scale(0.5, 2); -o-transform: rotate(10deg) scale(0.5, 2); -ms-transform: rotate(10deg) scale(0.5, 2);} translate(100p, 100p) local 100 100 100p (0,0) (0,0) 5 100p 100 100 {-webkit-transform: rotate(10deg) scale(0.5, 2) translate(100p, 100p); -moz-transform: rotate(10deg) scale(0.5, 2) translate(100p, 100p); -o-transform: rotate(10deg) scale(0.5, 2) translate(100p, 100p); -ms-transform: rotate(10deg) scale(0.5, 2) translate(100p, 100p);} Local SAMPLE A SAMPLE A SAMPLE A 257
5 Chapter 5 (0,0) skewx (30deg) 30 30 (0,0) (0,0) (0,0) 30deg skewy(30deg) 30 30 30 {-webkit-transform: skewx(30deg); -moz-transform: skewx(30deg); -o-transform: skewx(30deg); 30deg -ms-transform: skewx(30deg);} (0,0) (0,0) skew(30deg) 30 <> bo (0,0) (0,0) 30 {-webkit-transform: skewy(30deg); -moz-transform: skewy(30deg); -o-transform: skewy(30deg); -ms-transform: skewy(30deg);} 30 {-webkit-transform: skew(30deg); -moz-transform: skew(30deg); -o-transform: skew(30deg); -ms-transform: skew(30deg);} 258
transform SAMPLE B translate() scale() skew() translate() skew() 0scale() SAMPLE C matri() a b 0 c d 0 e f 1 3 3 translate(t, T) transform T T translatex(t) translatey(t) scale(s, S) scalex(s) scaley(s) rotate(a) A skew(a, A) skewx(a) skewy(a) S S A A 5 matri(a, b, c, d, e, f) a f <> 10 matri(1, 0, 0, 1, T, T) T T matri() 10 cos(10)=0.985 sin(10)=0.174 {-webkit-transform: matri(0.985,0.174,-0.174,0.985,0,0); -moz-transform: matri(0.985,0.174,-0.174,0.985,0,0); -o-transform: matri(0.985,0.174,-0.174,0.985,0,0); -ms-transform: matri(0.985,0.174,-0.174,0.985,0,0);} matri(s, 0, 0, S, 0, 0) <>HAM SANDWICHES</> S S matri(cos(a), sin(a), -sin(a), cos(a), 0, 0) A matri(1, tan(a), tan(a), 1, 0, 0) A A SVG 2D SVG Scalable Vector Graphics (SVG) 1.1 (Second Edition) 7 Coordinate Sstems, Transformations and Units http://www.w3.org/tr/svg/coords.html 259