Css In Iterations

26
CSS IN ITERATIONS Created by Vladimir Zhydal

Transcript of Css In Iterations

Page 1: Css In Iterations

CSS IN ITERATIONSCreated by Vladimir Zhydal

Page 2: Css In Iterations

LEVEL 1“Html/Css are for html coders only”

Page 3: Css In Iterations

INLINE STYLES<div style="background: red; margin: 10px; padding: 10px;"></div><div style="background: green; margin: 10px; padding: 10px;"></div><div style="background: blue; margin: 10px; padding: 10px;"></div>

Page 4: Css In Iterations

RESULTSAlmost impossible to maintain.Almost impossible to make themes.Widespread duplication of code.

Page 5: Css In Iterations

IMPULSEI can avoid duplication.

Page 6: Css In Iterations

<STYLE><style>

</style><div style="background: red;"></div><div style="background: green;"></div><div style="background: blue;"></div>

div margin: 10px; padding: 10px;

Page 7: Css In Iterations

RESULTSThere is no so many copy-paste.Super hard to maintain.Super hard to make themes.

Page 8: Css In Iterations

IMPULSEI can separate content and styles.

Page 9: Css In Iterations

LEVEL UP

Page 10: Css In Iterations

LEVEL 2“Let’s see how html coders do that”

Page 11: Css In Iterations

FIRST STEPS OF SEPARATIONLet’s use separate files for styles and html.Let’s use ids (just because they are fast).

Page 12: Css In Iterations

<LINK>

<link href="index.html" rel="stylesheet"<div id="red­container"></div><div id="green­container"></div><div id="blue­container"></div>

div margin: 10px; padding: 10px;#red­container background: red;#green­container background: green;#blue­container background: blue;

Page 13: Css In Iterations

RESULTSPossible to make themes.Still hard to maintain.High coupling.A lot of side effects.

Page 14: Css In Iterations

IMPULSEId => class (because ids cannot be reused through thehtml code).Think about structure.Think about semantics in naming.

Page 15: Css In Iterations

COMMENTS FOR DEFININGSTRUCTURE

.container margin: 10px; padding: 10px;/****** HEADER *******/.header background: red;/****** END HEADER *******/

/****** BODY *******/.content background: red;/****** END BODY *******/

Page 16: Css In Iterations

RESULTSA bit easier to maintain (just because it’s easier to findsome logical parts).There is a big chance to place a style to a wrong group.

Page 17: Css In Iterations

IMPULSEPlace logical parts of your styles in separate files.Performance optimizations shouldn't affect projectstructure.It’s possible to use build tools instead of developing inone file.

Page 18: Css In Iterations

DEEP NESTING(CSS COUPLED TO DOM)

.container div color: red;.container div .container ul color: green;.container div .container ul li a span color: blue;

Page 19: Css In Iterations

RESULTSHard to maintain.Hard to read and modify.Hard to override.

Page 20: Css In Iterations

ONE LINE STYLES.container div color: red;.container div .container ul color: green;.container div .container ul li a span color: blue;

Page 21: Css In Iterations

RESULTSBig problems with VCS.Hard to maintain.Super hard to read and modify.Hard to override.

Page 22: Css In Iterations

IMPULSEI can make my project more structured and maintainablewith some modules.Naming and semantic are really important.

Page 23: Css In Iterations

LEVEL UP

Page 24: Css In Iterations

LEVEL 3“I’m not an html coder, but I’m a programmer. I can do

better!”

Page 25: Css In Iterations

THINK ABOUT SCALABLE ANDMODULAR CSS

Scalable and Modular Architecture for CSSObject Oriented CSSDon’t Repeat Yourself CSSBlock, Element, Modifier

Page 26: Css In Iterations

THINK IN MODULESAfter getting a mockup try to split it to modules.Make it possible to reuse your modules.Write container independent CSS.Use strong naming conventions.