0
Chandleryu<br />2011.06.30<br />
The Grid’s the Thing<br />CSS was not designed to describe 2D grids. Rather, CSS assumes that every page will be made up o...
. <br />
Tables Do the Trick<br />Absolute positioning and floated blocks can be employed to force blocks to sit alongside other bl...
The Layout We Want to Create<br />
Current Techniques: Absolute<br />
Current Techniques: Absolute<br />
Current Techniques: Float<br />
Current Techniques: oocss Float<br />/* ====== Columns ====== */<br />.main{overflow:hidden;_overflow:visible;_zoom:1;}<br...
Block Formatting Context<br />只要条件合适,任何块级元素都可以建立一个新的Block Formatting Context,以下是触发属性:<br />float:left<br />float:right<br ...
Table-relative value<br />Internet Explorer 8 will support many new values for the CSS display property, including the tab...
Using CSS Tables<br />
Using CSS Tables<br />
Internet Explorer 8+, Firefox, Safari, Opera<br />Our three-column equal-height layout is achieved without having to resor...
Hang on … Aren’t Tables for Layout Wrong? <br />The table value of the display property, on the other hand, is simply an i...
Anonymous Table Elements<br />if we use display: table-cell; without first containing the cell in a block set to display: ...
Anonymous Table Elements<br /> .main{overflow:hidden;_overflow:visible;_zoom:1;}<br />Can be replaced by:<br />.main{displ...
Table-cell/table生成BFC的缺点<br />无论是table-cell还是table,如果内部有元素宽度宽于table-cell/table的设定宽度,那么设定宽度无效。<br />
Solution<br />.col2 {display:tablecell; *zoom:1; background:green;}<br />.col2_inner{width:500px;overflow:hidden;backgroun...
Flexible Layout<br />
Flexible Layout<br />
Nest<br />
Position<br />
Colspan/rowspan<br />CSS tables lack any concept of row or column spanning, making it trickier to use one single layout st...
Colspan/rowspan<br />
Do I have to change the source order?<br />search engine optimization<br />accessibility<br />
SEO<br />The truth is, however, that source order has little impact on either of those areas. Of far more importance than ...
Skip Links<br />
Support for CSS Tables<br />
Option 1:Ignore Older Browsers<br />If you’re designing for yourself and nobody else, this is an option you might want to ...
Option 2:A Simplified Layout<br />
Option 3:Reproduce<br />What you need to do is reproduce your table-based layout as closely as possible using the features...
Why Not Stick with Floated Layouts?<br />If we don’t start using those features now, then who’s holding back the Web? The ...
CSS3 Multi-column Layout Module<br />
CSS3 Multi-column Layout Module<br />
CSS3 Multi-column Layout Module<br />
CSS3 Grid Positioning Module<br />Imagine being able to define a grid for your page, then snap elements to that grid!<br />
CSS3 Grid Positioning Module<br />In the case of a body with no width applied, they’d evenly stretch if the window was res...
CSS3 Grid Positioning Module<br />Since this is a repeating pattern, we can also use the following notation instead of spe...
CSS3 Grid Positioning Module<br />Since this is a repeating pattern, we can also use the following notation instead of spe...
CSS3 Grid Positioning Module<br />
CSS3 Template Layout Module<br />
CSS3 Template Layout Module<br />We’d like to display the list as three columns.<br />
CSS3 Template Layout Module<br />To set up the three-column template, we use the <br />display property with a value of “a...
CSS3 Template Layout Module<br />Positioning Elements into the Slots<br />
CSS3 Template Layout Module<br />CSS3 templates can be even more complex than that. We don’t have enough room in this book...
CSS3 Template Layout Module<br />
Everything You Know about CSS is Wrong<br />By keeping your techniques up to date and not expecting life to remain the sam...
Thank U<br />
Everything You know about CSS is Wrong
Upcoming SlideShare
Loading in...5
×

Everything You know about CSS is Wrong

2,151

Published on

Everything You know about CSS is Wrong

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,151
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
41
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Transcript of "Everything You know about CSS is Wrong"

  1. 1. Chandleryu<br />2011.06.30<br />
  2. 2.
  3. 3.
  4. 4.
  5. 5. The Grid’s the Thing<br />CSS was not designed to describe 2D grids. Rather, CSS assumes that every page will be made up of a vertical stack of blocks, piled(堆叠) one on top of another, each containing either another stack of blocks, or text (called inline content) wrapped to fit inside the block. <br />
  6. 6. . <br />
  7. 7.
  8. 8. Tables Do the Trick<br />Absolute positioning and floated blocks can be employed to force blocks to sit alongside other blocks—a purpose never envisioned by its creators. <br />
  9. 9.
  10. 10. The Layout We Want to Create<br />
  11. 11. Current Techniques: Absolute<br />
  12. 12. Current Techniques: Absolute<br />
  13. 13. Current Techniques: Float<br />
  14. 14. Current Techniques: oocss Float<br />/* ====== Columns ====== */<br />.main{overflow:hidden;_overflow:visible;_zoom:1;}<br />.leftCol{float:left; width:250px;_margin-right:-3px;}<br />.rightCol{float:right; width: 300px;_margin-left:-3px;}<br />
  15. 15. Block Formatting Context<br />只要条件合适,任何块级元素都可以建立一个新的Block Formatting Context,以下是触发属性:<br />float:left<br />float:right<br />position:absolute<br />display:inline-block<br />display:inline-table<br />display:table-cell<br />display:table<br />overflow:auto<br />overflow:scroll<br />overflow:hidden(也就是除了overflow:visible;)<br />
  16. 16. Table-relative value<br />Internet Explorer 8 will support many new values for the CSS display property, including the table-related values: table, table-row, and table-cell—and it’s the last major browser to come on board with this support. <br />
  17. 17. Using CSS Tables<br />
  18. 18. Using CSS Tables<br />
  19. 19. Internet Explorer 8+, Firefox, Safari, Opera<br />Our three-column equal-height layout is achieved without having to resort to tricks <br />like faux(假的)columns using background images, worrying about positioning, or having <br />to clear floats—revolutionary! <br />
  20. 20. Hang on … Aren’t Tables for Layout Wrong? <br />The table value of the display property, on the other hand, is simply an indi­cation of how something should look in the browser—it has no semantic meaning.<br />
  21. 21. Anonymous Table Elements<br />if we use display: table-cell; without first containing the cell in a block set to display: table-row;, the row will be implied—the browser will act as though the declared row is actually there. <br />
  22. 22. Anonymous Table Elements<br /> .main{overflow:hidden;_overflow:visible;_zoom:1;}<br />Can be replaced by:<br />.main{display:table-cell;_overflow:visible;_zoom:1;}<br />Or<br />.main{display:table;_overflow:visible;_zoom:1;}<br />
  23. 23. Table-cell/table生成BFC的缺点<br />无论是table-cell还是table,如果内部有元素宽度宽于table-cell/table的设定宽度,那么设定宽度无效。<br />
  24. 24. Solution<br />.col2 {display:tablecell; *zoom:1; background:green;}<br />.col2_inner{width:500px;overflow:hidden;background:yellow;}<br />
  25. 25.
  26. 26. Flexible Layout<br />
  27. 27. Flexible Layout<br />
  28. 28. Nest<br />
  29. 29. Position<br />
  30. 30. Colspan/rowspan<br />CSS tables lack any concept of row or column spanning, making it trickier to use one single layout structure than what might have been possible when using HTML tables. However, similar layouts can be achieved by using nested CSS tables. <br />
  31. 31. Colspan/rowspan<br />
  32. 32. Do I have to change the source order?<br />search engine optimization<br />accessibility<br />
  33. 33. SEO<br />The truth is, however, that source order has little impact on either of those areas. Of far more importance than source order is a proper heading structure: a properly nested sequence of heading tags (<h1> to <h6>) to clearly identify the page topic and sections.<br />
  34. 34. Skip Links<br />
  35. 35.
  36. 36. Support for CSS Tables<br />
  37. 37. Option 1:Ignore Older Browsers<br />If you’re designing for yourself and nobody else, this is an option you might want to consider—it’ll certainly save you some time, and if you’re looking to make a point, this is the most visible way to do it. <br />
  38. 38. Option 2:A Simplified Layout<br />
  39. 39. Option 3:Reproduce<br />What you need to do is reproduce your table-based layout as closely as possible using the features available in IE6 and 7.<br />
  40. 40. Why Not Stick with Floated Layouts?<br />If we don’t start using those features now, then who’s holding back the Web? The users who haven’t upgraded their browsers? Until we build sites that take advantage of the new features added to the latest browsers, how can we expect those users to upgrade? <br />Microsoft has done its part; now it’s our turn. <br />
  41. 41.
  42. 42. CSS3 Multi-column Layout Module<br />
  43. 43.
  44. 44. CSS3 Multi-column Layout Module<br />
  45. 45. CSS3 Multi-column Layout Module<br />
  46. 46. CSS3 Grid Positioning Module<br />Imagine being able to define a grid for your page, then snap elements to that grid!<br />
  47. 47. CSS3 Grid Positioning Module<br />In the case of a body with no width applied, they’d evenly stretch if the window was resized. <br />
  48. 48. CSS3 Grid Positioning Module<br />Since this is a repeating pattern, we can also use the following notation instead of specifying all of the columns individually: <br />
  49. 49. CSS3 Grid Positioning Module<br />Since this is a repeating pattern, we can also use the following notation instead of specifying all of the columns individually: <br />
  50. 50. CSS3 Grid Positioning Module<br />
  51. 51. CSS3 Template Layout Module<br />
  52. 52. CSS3 Template Layout Module<br />We’d like to display the list as three columns.<br />
  53. 53. CSS3 Template Layout Module<br />To set up the three-column template, we use the <br />display property with a value of “abc”, a letter for each template slot(槽).<br />
  54. 54. CSS3 Template Layout Module<br />Positioning Elements into the Slots<br />
  55. 55. CSS3 Template Layout Module<br />CSS3 templates can be even more complex than that. We don’t have enough room in this book to speculate on all the possibilities<br />
  56. 56.
  57. 57. CSS3 Template Layout Module<br />
  58. 58. Everything You Know about CSS is Wrong<br />By keeping your techniques up to date and not expecting life to remain the same, you can ensure that you’re not left behind as techniques and support move on. <br />
  59. 59. Thank U<br />
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×