310 likes | 470 Views
In the name of GOD. Welcome to 7 th session HTML/CSS. CSS Fundamentals. Begin styling by CSS. CSS Selectors. Child selector p a { } Direct Child selector p > a { } Multiple selectors : h1, h2 { }. Tag selector : h1 { } Class selector : .header { } ID Selector : #wrapper {
E N D
In the name of GOD Welcome to 7thsession HTML/CSS
CSS Fundamentals Begin styling by CSS
CSS Selectors • Child selector p a { } • Direct Child selector p > a { } • Multiple selectors: h1, h2 { } • Tag selector: h1 { } • Class selector: .header { } • ID Selector: #wrapper { }
CSS Selectors • Wildcard selector * { } • Adjacent selector (immediately after) .content + div { } • Sibling selector (all siblings after tag): ul ~ p { } • Mixed selectors: • h1.header {} • div#wrapper {} • .content p a.external {} • body>div {} • table tr {} • #navigation ul.menu {} • ul.menu li li {} • body.js .slider img {}
CSS Selectors (Attribute selectors)(CSS3) • Attribute value starts with a[href^=“http”] { } • Attribute value ends with A[href$=“.jpg”] { } • Attribute value contains (space separated values): a[href~=“tutorial”] { } • Has attribute: a[title] { } • Attribute value is equal to a[href=“http://xx.com/”] { } • Attribute value contains: a[href*=“tutorial”] { }
CSS Pseudo selectors (+CSS3, +jQuery) • Focused element input[type=“submit”]:focus, button:focus { } • Checked element Input[type=“radio”]:checked {} input:checked {} • Negation selector *:not(p) {} p:not(.content p) {} • Normal links: a:link { } • Visited links a:visited { } • Hover effect (only links – CSS3=all tags): a:hover {} input[type=“text”]:hover{}
Formatting text Basic text formatting, fonts, colors, etc…
Fonts p { font-family: Tahoma, Verdana, Geneva, sans-serif; font-size: 13px; color: #000; /* Foreground color */ background-color: #fff; /* Background color */ } p.transparent { background-color: transparent; }
Text decoration a { text-decoration: none; } a:hover { text-decoration: underline; }
Text alignment .content { text-align: center; text-align: left; text-align: right; text-align: justify; }
Text Direction body.language-fa { direction: rtl; } body.language-en { direction: ltr; }
CSS Rule inheritance & default values p { text-align: inherit; }
Text: line height P { line-height: 10px; }
Text: Shadow (CSS3) Pattern: text-shadow: horizontalvertical [blur-level] [color]; Example: p { text-shadow: 2px 2px 3px #f00; -moz-text-shadow: 2px 2px 3px #f00; -webkit-text-shadow: 2px 2px 3px #f00; }
Text: Spacing Word spacing: p { word-spacing: 30px; } Letter spacing: p { letter-spacing: 10px; }
CSS Box Model & Positioning Padding, Margin, Border
The Box model: Calculate Dimensions Calculate total (Applied) width and height: Total width = Width + padding-left + padding-right + border-left + border-right + margin-left + margin-right Total Height = Height + padding-top + padding-bottom + border-top + border-bottom + margin-top + margin-bottom
The Box model: Border div.example { border-style: dotted; border-style: dashed; border-style: solid; border-style: groove; border-style: double; border-style: inset; border-style: outset; }
The Box model: Border: Width & Color div.example { border-width: 1px; border-style: dashed; border-color: red; }
The Box model: Border : shorthand style Notice the order: border: [border-width] border-style [border-color]; div.example { border: 1px solid red; border: 1px dashed green; border: 5px groove #000; }
The Box model: Margin Example: div.example { margin: 10px; margin: 10px 15px; } Default value: margin: inherit; Calculate by browser: margin: auto; Syntax: clockwise margin: top right bottom left; margin: vertical horizontal; margin: top horizontal bottom; margin-top: 3px; margin-right: 3px; margin-bottom: 1em;
The Box model: Padding Example: div.example { padding: 10px; padding: 10px 15px; } Syntax: clockwise padding: top right bottom left; padding: vertical horizontal; padding: top horizontal bottom; padding-top: 3px; padding-right: 3px; padding-bottom: 1em;
Real world example of the box model Step by step creating a vCard: Place a division in the center of the screen
Place in the center horizontally #wrapper { width: 850px; margin: 0 auto; border: 1px solid #000; } Step 1: Set a fixed with. Step 2: Set margin-left and margin-right to auto. Step 3: Done!
Setup border-radius (CSS3 + Fallback) #wrapper { border-radius: 15px; } http://border-radius.com/ http://css3generator.com/ Syntax: border-radius: toprightbottomleft; border-radius: verticalhorizontal; border-radius: all; -moz-border-radius: ; -webkit-border-radius: ;
Setup box-shadow (CSS3 + Fallback) #wrapper { box-shadow: 10px 10px 5px #888888; } Syntax: box-shadow: horizontal shadow vertical shadow blur-level spread (size) color inset;
Your public website Put your awesome works online !
Login to FTP using My Computer or FileZilla Address: ftp://hejazee.ir/ Username: payamenoor Password: htmlcourse Web access URI: http://www.hejazee.ir/~payamenoor/
Make your own with your name • You can ask me to create a special user for you. • You can register your own domain name (this one comes with a little price) • You can buy a web hosting space or ask me for this. • You can register free domains @ www.dot.tk • You can get free hosting by searching in google