קורס מזורז ב- css

מדוע והיכן

* מדוע css ?

* היכן לשים הגדרות css ?

inline, on a specific HTML element:
<div style="color:red; font-family:Arial;"> ... </div>
in the HEAD section:
<style>
DIV {color:red}
TABLE {background-color:purple;}
</style>
in an external file:
<link rel="stylesheet" href="telem.css" type="text/css">

* css של האפליקציה, של המשתמש, ושל מחבר העמוד

ה cascade .
!important משמעותי בעיקר ב css של המשתמש.

הערות ב css

רק /* .... */
אפשר multiline .

Selectors

by type:
BODY {margin:0px; padding:0px; color:navy}
DIV {margin-top:10px; margin-bottom:0px;}
by class:
DIV.special {color:red}
DIV.remark {font-weight:bold}
.english {direction:ltr; }
by ID:
DIV#header {border:solid 3px green;}
by descendance:
DIV.special IMG {border:solid 1 px blue;}
DIV.special DIV.remark {background-color:oldlace}
DIV#header TD TD LI {background-color:lime;}
by child, by nextSibling, by First-child, by attribute value, ....
css2 , not supported by current IE - לא להשתמש
by Pseudo-class:
A:link {color:blue; text-decoration:none}
A:hover {text-decoration:underline}
A:visited {color:gray; text-decoration:none;}

DIV:first-line {font-weight:bold;}
DIV:first-letter {font-size:1.5em;}
grouping selectors (do not confuse w descendance) :
H1, H2, H3 {background-color:yellow}

התיבה - the Box Model

* width, height, padding, margin, border - הסבר

example :
DIV#moo {width:400px; height:250px; padding-top:10px; padding-right:20px; margin:0px; border-color:red; border-width: 2px; border-style:solid;}
shorthand notation:
P {margin:5px 15px; padding:5px; border:solid 2px green; border-right:dashed 5px red;}
margin can be negative:
P {margin-top:-15px; margin-right:20px;}

* עץ ה- layout, או ה- offset , להבדיל מעץ ה- HTML.

מיקום - Positioning and stacking

absolute:
position:absolute; top:50px; left:50px;
absolute right (shifted relative to the right edge!) :
position:absolute; top:50px; right:50px;
relative:
position:relative; top:25px;
relative can be negative:
position:relative; top:-25px; left:50px;
stacking:
z-index:5;
יחסית למה מחושבים ה top, left, right, bottom של מיקום מוחלט?
אם האלמנט הוא חלק מהזרימה הרגילה של המסמך, זה מחושב יחסית ל body .
אבל אם האלמנט הוא צאצא של אלמנט שבעצמו ממוקם אבסולוטית או יחסית - זה מחושב יחסית לשוליים של האלמנט הזה!

display, visibility, float, overflow

display:
block, inline, none (there are other values but do not use them)
visibility:
visible, hidden
float:
left, right, none
overflow:
visible, hidden, scroll

טקסט: גופן, גודל, צבע, רקע, יישור

font styles:
LI {font-family:Narkisim, Frankreuhel, Arial;
font-size:12pt; font-weight:bold;
line-height:25px;
text-decoration:line-through;
color:navy; background-color:lightblue;}
background:
DIV.bg {background-image: url("marble.png") }
alignment of content:
DIV.hebrew {text-align:right}

מדיה

בתוך קטע style
@media print { ...}
@media screen { ...}
בקריאה לקובץ חיצוני
<link rel="stylesheet" href="telem.css" type="text/css" media="print">

שאריות

direction (not dir !) :
rtl, ltr
cursor :
pointer (W3C) = hand (IE)
cross-browser "hand" cursor:
{cursor:pointer; cursor:hand;}
page setup:
@page, page-break-before, page-break-after, see the spec or style editor.
scrollbar colors
only IE, see MSDN or style editor.
list style, list style image, etc. :
see the spec or style editor.
white-space:
normal, pre, nowrap (more values not to be used)

Scripting the styles

<div id="moo" class="nice"> ....</div>
script it:
document.getElementById("moo").className = "ugly";
<div id="moo" style="color:red"> ....</div>
script it:
document.getElementById("moo").style.color="blue";

* element.style מתייחס רק ל- inline style .

בכתיבת התכונה זה לא מורגש, אבל בקריאת התכונה זה עשוי להטעות.
currentStyle, computedStyle .

לקריאה ול reference

w3c style section
   w3c css 2.1 spec

Quirksmode - מומלץ !

כלי עבודה מומלץ : TopStyle Lite

תצוגת תכלית מרשימה: css zen garden