css for developers

30
CSS for Developers Anjaneyulu Reddy BEERAVALLI Email: [email protected] Twitter: @_anji KNOLSKAPE Solutions Pvt Ltd

Upload: b-anjaneyulu-reddy

Post on 28-Jan-2015

461 views

Category:

Technology


1 download

DESCRIPTION

In this presentation we will see the basics of CSS, few selectors from a developers perspective.

TRANSCRIPT

Page 1: CSS for developers

CSS for Developers

Anjaneyulu Reddy BEERAVALLIEmail: [email protected]

Twitter: @_anjiKNOLSKAPE Solutions Pvt Ltd

Page 2: CSS for developers

CSS is a query language

Page 3: CSS for developers

.a {font-size: 12px;

}

SELECT aFROM domWHERE classname = 'a'

Page 4: CSS for developers

Properties

Page 5: CSS for developers

Selectors - The 23

Page 6: CSS for developers

** {

margin: 0;padding: 0;

}

#container * {border: 1px solid black;

}

Page 7: CSS for developers

x

x - tagname

x {background-color: blue;

}

Page 8: CSS for developers

#x#container {

border: 1px solid black;}

Page 9: CSS for developers

.x

.error {color: red;

}

Page 10: CSS for developers

x y

Select all `y` which are descendants of `x`

li a {text-decoration: none;

}

Page 11: CSS for developers

a:visited a:link

":<param>" - pseudo class elements

a:visited {color: red;

}

a:link {color: purple;

}

Page 12: CSS for developers

x + y

select first `y` adjacent to `x`

ul + p {color: red;

}

Page 13: CSS for developers

x > yselect all `y` which are direct children to `x`

div#container > ul {

border: 1px solid black;

}

<div id="container">

<ul>

<li> List Item

<ul>

<li> Child </li>

</ul>

</li>

<li> List Item </li>

<li> List Item </li>

<li> List Item </li>

</ul>

</div>

Page 14: CSS for developers

x ~ y

select all `y` adjacent to `x`

ul ~ p {color: red;

}

Page 15: CSS for developers

x[attr]

attribute selector: select all x which have attribute `title`

a[title] { color: green;}

Page 16: CSS for developers

x[attr="z"]

attribute selector: select all x which have attribute `attr` whose value is equal = z

a[href="www.google.com"] { color: green;}

// multiple attributesa[href="www.google.com"][title="google"] {

color: green;}

Page 17: CSS for developers

a[href*="tuts"]

attribute selector: select all anchor tags which have attribute `href` whose value contains the word `tuts`

a[href*="tuts"] { color: green;}

Page 18: CSS for developers

a[href^="http"]

attribute selector: select all anchor tags which have attribute `href` whose value start with the word `http`

a[href^="http"] { color: green;}

Page 19: CSS for developers

a[href$=".jpg"]

attribute selector: select all anchor tags which have attribute `href` whose value end with the word `.jpg`

a[href$=".jpg"] { color: green;}

Page 20: CSS for developers

x:checked

Used of radio buttons and checkboxes.

input[type=radio]:checked { border: 1px solid black;}

Page 21: CSS for developers

x:after

A special pseudo class which can add content

.clearfix:after { content: ""; display: block; clear: both; visibility: hidden; height: 0;}

.clearfix { display: inline-block;}

Page 22: CSS for developers

x:before

A special pseudo class which can add content

.clearfix:before { content: ""; display: block; clear: both; visibility: hidden; height: 0;}

.clearfix { display: inline-block;}

Page 23: CSS for developers

x:hover

action pseudo class

div:hover { background: #e3e3e3;}

Page 24: CSS for developers

x:not(selector)div:not(#container) { background: #e3e3e3;}

Page 25: CSS for developers

x:nth-child(n)1 based indexing

li:nth-child(3) { color: red;}

li:nth-child(4n) { color: red;}

Page 26: CSS for developers

x:nth-last-child(n)1 based indexing. begins at end of the collection

li:nth-last-child(3) { color: red;}

li:nth-child(4n) { color: red;}

Page 27: CSS for developers

x:first-childul li:first-child { border-top: none;}

Page 28: CSS for developers

x:last-childul > li:last-child { border-top: none;}

Page 29: CSS for developers

Questions?

Page 30: CSS for developers

Thank You