API CSS

86
API CSS

description

API CSS is the CSS Method to use the CSS as API that rarely modified. It works really well.

Transcript of API CSS

Page 1: API CSS

API CSS

Page 2: API CSS

I canexplain

Page 3: API CSS

Why CSS Sucks

for you.

Page 4: API CSS

You are trapped by

Page 5: API CSS

CSS dogma

Page 6: API CSS

or

Page 7: API CSS

You don’t know the

basic rules.

Page 8: API CSS

Rule #1

Page 9: API CSS

Cascading

Page 10: API CSS

You know that.

Page 11: API CSS

But, how to stop it?

Page 12: API CSS

ul li {…}

Page 13: API CSS

ul li {…} ul li li {…}

Page 14: API CSS

ul li {…} ul li li {…} ul li li li {…}

Page 15: API CSS

¯\_(ツ)_/¯

Page 16: API CSS

Try this:

Page 17: API CSS

ul > li {…}

Page 18: API CSS

or

Page 19: API CSS

Useclassed div

Page 20: API CSS

.list-item {…}

Page 21: API CSS

Trust me, It works.

Page 22: API CSS

Rule #2

Page 23: API CSS

Specificity

Page 24: API CSS

What’s that?

Page 25: API CSS

Forexample:

Page 26: API CSS

<h1 class=“blue red pink”>

Page 27: API CSS

Which color is applied?

Page 28: API CSS

Pink?

Page 29: API CSS

Maybe

Page 30: API CSS

You can’ttell until

Page 31: API CSS

you go to check the Specificity.

Page 32: API CSS

.blue {color:blue}

.red {color:red}

.pink {color:pink}

Page 33: API CSS

If so,

Page 34: API CSS

h1

Page 35: API CSS

.blue {color:blue} h1.red {color:red} .pink {color:pink}

Page 36: API CSS

If so,

Page 37: API CSS

h1

Page 38: API CSS

Why?

Page 39: API CSS

.blue {color:blue} h1.red {color:red} .pink {color:pink}

Page 40: API CSS

h1.red {…}is more specific.

Page 41: API CSS

Orderdoesn't matter.

Page 42: API CSS

Unless

Page 43: API CSS

Specificities are all equal,

Page 44: API CSS

orderdo

matter.

Page 45: API CSS

Take care ofSpecificity.

Page 46: API CSS

Rule #3

Page 47: API CSS

Browsersare not

all same.

Page 48: API CSS

They are slightly

different.

Page 49: API CSS

Use the normalize

css.

Page 50: API CSS

http://necolas.github.io/

normalize.css

Page 51: API CSS

If you know the basics,

Page 52: API CSS

probablyyou heard

Page 53: API CSS

the CSS dogma,

Page 54: API CSS

Naming Convention.

Page 55: API CSS

“Class name should bea semantic phrase …

Page 56: API CSS

to prepare for modify the style in the future.”

Page 57: API CSS

like this,

Page 58: API CSS

.red {…}

Page 59: API CSS

.red {…}

Page 60: API CSS

.red {…} .caution {…}

Page 61: API CSS

.caution {…}

Page 62: API CSS

.caution {…}

more semantic

Page 63: API CSS

Forget this.

Page 64: API CSS

This idea is too old.

Page 65: API CSS

and against the software

development approach.

Page 66: API CSS

O.C.P.

Page 67: API CSS

Open/Closed Principal

Page 68: API CSS

“software entities should be open for

extension, …

Page 69: API CSS

but closed for modification.”

Page 70: API CSS

It’s true.

Page 71: API CSS

Trust me. (again)

Page 72: API CSS

You can't modify the existing

classes.

Page 73: API CSS

You can’t.

Page 74: API CSS

.caution {…}

Page 75: API CSS

.caution {…}

Page 76: API CSS

.caution {…} .color-red {…}

Page 77: API CSS

.color-red {…}

Page 78: API CSS

.color-red {…}

open for extension

closed for modification

Page 79: API CSS

.extention-modifier {…}

Page 80: API CSS

This is called

Page 81: API CSS

API CSS

Page 82: API CSS

Learn this.

Page 83: API CSS

Your CSS sucks

Page 84: API CSS

for more detail

Page 85: API CSS

http://byodkm.com/

apicss

Page 86: API CSS

Thank you.