Bảng kiểu CSS

Khái niệm DHTML

- Giớ thiệu CSS

- Cách hoạt ñộng của các CSS

- Syntax- qui tắc tạo CSS

- Phân loại CSS và cách sử dụng

pdf31 trang | Chuyên mục: CSS | Chia sẻ: dkS00TYs | Lượt xem: 2034 | Lượt tải: 2download
Tóm tắt nội dung Bảng kiểu CSS, để xem tài liệu hoàn chỉnh bạn click vào nút "TẢI VỀ" ở trên
 ChCh ươươ ng4:BngkiuCSSng4:BngkiuCSS
  KháinimDHTML
  GithiuCSS
  CáchhotñngcacácCSS
  Syntax quitctoCSS
  PhânloiCSSvàcáchsdng
15/08/2008 KhoaCNTT 1
 KháinimDHTMLKháinimDHTML
 DHTML(DinamicHyperTextMarkupLanguage)
 DHTML=HTML+CSS+ScriptLanguage
 CSS Cascading Style Sheets
 CSS  howtodisplay HTMLelements?
 Scriptlanguage– JavaScript,VBScript,PHP,ASP.NET,…Cho
 phépñưadliulêntrangwebñng:
 User Webpage
15/08/2008 KhoaCNTT 2
 GiithiuCSSGiithiuCSS
 CSS Cascading Style Sheets
 – Dùngñmôtcáchhinth cácthànhphntrên trangWEB
 – SdngtươngtnhưdngTEMPLATE
 – Cóthsdnglichocáctrangwebkhác
 – Cóththayñithuctínhtngtranghoccsite nhanhchóng
 (cascading)
 Bngkiuxácñnhcáchbtrí,trìnhbày,màusc,…
 chocáctagscaHTML
 VD:chotagbodymàuhng,chotagpmàuñ,loifontTimesNew
 Roman,loichnghiêng,…
 CSSñclutrong:
  BngkiunhúngtrongfileHTML
  BngkiungoitrútrongFilebngkiuriêngcóñuôi *.css
15/08/2008 KhoaCNTT 3
 ƯƯu,khuytñimcaCSSu,khuytñimcaCSS
 Ưuñim:
 Kimsoátbcctrang,kthutthitkphôngvàdngchtt
 hơn
 Dduytrìhotñngcasitehơn
 Thôngtinkiuñưctáchrakhicutrúcsite
  Khuytñim :
 Khôngñưchtrrngrãi,hochtrkhônght
15/08/2008 KhoaCNTT 4
 CáchhotñngcacácCSSCáchhotñngcacácCSS
 BngkiunhúngtrongfileHTML
 – Phnñnhdngkiuthưngñttrongtag
 – Cáckiutrongdòng:ñttrongmttag
 Dngkiunàoñưcdùngchotagkhicónhiukiu
 ñưcñnhnghĩachonó?
 – Browserdefault
 – Externalstylesheet
 ðưutiêntăng
 – Internalstylesheet(insidethetag)
 – Inlinestyle(insideanHTMLelement)
15/08/2008 KhoaCNTT 5
 SyntaxSyntax  quitctoCSSquitctoCSS
 TheCSSsyntaxismadeupofthreeparts:a
 selector,apropertyandavalue:
 selector {property : value }
 p
 body{color:black} {
 p{fontfamily: "sansserif "} textalign:center ;
 color:black;
 p{textalign:center;color:red} fontfamily:arial
 }
15/08/2008 KhoaCNTT 6
 CácgiátrkíchthưcphôngchfontCácgiátrkíchthưcphôngchfont 
 sizesize
 – Cácgiátrñln:
 • Px  Pixel
 • Pt  Point
 • Pc  pica
 • In  inch
 • Mm  milimet
 • Cm  centimet
 – Phntrăm%
 – Tươngñi:
 • Larger
 • Smaller
 – Kíchthưctuytñi:xxsmall,xsmall,small,medium,large,x
 large,xxlarge
15/08/2008 KhoaCNTT 7
 PhânloiCSSvàcáchsdngPhânloiCSSvàcáchsdng
 Gm3loiCSS
 1.InlineStyleSheet
 2.EmbeddingStyleSheet
 3.ExternalStyleSheet
15/08/2008 KhoaCNTT 8
 InlineStyleSheetInlineStyleSheet
  ðnhnghĩastyletrongthuctínhstylecatngtag
 HTML
  Syntax(kiu1):
 <TagNamestyle=“property1:value1;
 property2:value2;
 ……..
 propertyN:valueN;”>Dliucatag
  Víd:
 Thisisa
 paragraph
15/08/2008 KhoaCNTT 9
 EmbeddingStyleSheetEmbeddingStyleSheet
  NhúngtrongtagcatrangHTML
  Syntax(kiu2):
 <!
 SelectorName
 {
 property1:value1;
 property2:value2;
 ………
 propertyN:valueN;
 }
 ….
 >
15/08/2008 KhoaCNTT 10
 VDEmbeddingStyleSheetVDEmbeddingStyleSheet
 p
 {
 color:blue;
 fontsize:14pt;
 fontfamily:Verdana;
 textalign:center
 }
 p.left{textalign:left}
 DinhdangtrongPmau bluefontco14
 Trongclassleft
15/08/2008 KhoaCNTT 11
 ExternalStyleSheetExternalStyleSheet
  Mistyleñulưutrongfilecóphnmrnglà *.css*.css
  SyntaxgingnhưtrongembeddingSS
  ðdùngbngkiucntoliênktñnfileCSS
 bng2cách:
 1. Liênktbngtaglink.Cúpháp:
 2. Liênktbngtagstyledùng @import url.
 @import url (URL );
15/08/2008 KhoaCNTT 12
 VDExternalStyleSheetVDExternalStyleSheet
  DùngfileCSSriêng:
 Trongfile“ex1.css”:
 body{backgroundcolor:yellow}
 h1{fontsize:36pt}
 h2{color:blue}
 p{marginleft:50px}
 
 
 Chúý:không 
 táchri 
Cáchkhác: Thisheaderis36pt 
 Thisheaderisblue
 @importurl(ex1.css) Thisparagraphhasaleftmarginof50pixels 
 15/08/2008 KhoaCNTT 13
 Sosánh,ñánhgiá3loiCSSSosánh,ñánhgiá3loiCSS
15/08/2008 KhoaCNTT 14
 QuitctoSelectorQuitctoSelector
 Quitcñơngin:
 p
 {
 textalign:center ;
 color:black;
 fontfamily:arial
 }
 Grouping
 h1,h2,hr
 h1{color:green} Nhómcácb
 {
 h2{color:green} chncách
 nhaubidu color:green
 hr{color:green} phy }
15/08/2008 KhoaCNTT 15
 Dngñakiu(Multiplestylesheets)Dngñakiu(Multiplestylesheets)
 extenalstyle:
 h3 Internalstyle:
 { h3
 color:red; {
 textalign:left; textalign:right;
 fontsize:8pt fontsize:20pt
 } }
 color:red;
 textalign:right;
 fontsize:20pt
15/08/2008 KhoaCNTT 16
 QuitctoSelector(tt)QuitctoSelector(tt)
 BchnthuctínhBchnthuctính classclass
 TheclassSelector
 p.right{textalign:right}
 p.center{textalign:center}
 Thisparagraphwillberightaligned.
 
 
 Thisparagraphwillbecenteraligned.
 .center{textalign:center}
 Thisheadingwillbecenteraligned
 Thisparagraphwillalsobecenteraligned.
15/08/2008 KhoaCNTT 17
 QuitctoSelector(tt)QuitctoSelector(tt)
 Bchnthuctính class
 – Trongtrưnghpcóhơnmtclasschomtphntkiu?
 dl.center
 {
 Do NOT startaclassname
 textalign:center; withanumber!Itwillnotwork
 color:blue inMozilla/Firefox.
 }
 dl.bold{fontweight:bold}
 ….
 TrongphanDLcocentervabold
 p.right{textalign:right}
 p.left{textalign:left}
 Trongclassleft
 Trongclassright
 Trongclassrightvaleft???
15/08/2008 KhoaCNTT 18
 QuitctoSelector(tt)QuitctoSelector(tt)
 BchnthuctínhBchnthuctính IDID (TheidSelector)(TheidSelector)
 #green{color:green}
 p#para1
 {
 textalign:center;
 color:red
 }
 VD:
 Tintcthtrưng
 Thtrưngchngkhoán
 Do NOT startanIDnamewithanumber!Itwillnotworkin
 Mozilla/Firefox.
15/08/2008 KhoaCNTT 19
 CSSCommentsCSSComments
  GingtrongC++
 /*Thisisacomment*/
 p
 {
 textalign:center;
 /*Thisisanothercomment*/
 color:black;
 fontfamily:arial
 }
15/08/2008 KhoaCNTT 20
 ThTh divdiv vàvà spanspan (( ContextualSelection)
 Phnttrangtheoý,khôngcóthuctínhchdùng
 class
 – div :ñnhdngchomtvùngvănbn
 – span :ñnhdngchomtdòngvănbn
 .mauxanh{color:blue}
 Mtngưi
 cóvănhóaphixrácñúngnơiqui
 ñnh
 ToHuu
 Batrămnămnaaibitñâu
 ThiênhhànhânkhócTNhư
15/08/2008 KhoaCNTT 21
 VDThVDTh divdiv vàvà spanspan
 .mauxanh {color:blue}
 .mauhatde {color:maroon}
 ToHuu
 Batrămnămnaaibitñâu
 ThiênhhànhânkhócTNhư
 Mtngưicóvănhóaphixrácñúngnơi
 quiñnh
15/08/2008 KhoaCNTT 22
 BchngiBchngi  PseudoClass
 Bchngi:ñưcxácñnhbiduhaichm
 p:firstline{fontsize:larger}
 p:firstletter{fontsize:24px;color:orange}
 ðnhdngdavàotrngtháicaliênkt,skinchut.
 CóthkthpviSelectorkhác.Thưngñưcdùng
 vicáclink VD:
 – a:link a:link{color:blue;text
 – a:visited decoration:none}
 a:hover{color:red;font
 – a:hover weight:bold}
 – a:active a:visited{color:purple;}
 a:active{color:yellow;}
 Linkto
 LHU
15/08/2008 KhoaCNTTLink 23
 toMOET
 Link
 PseudoElement
 ðnhdngdavàovtríñutiên cakýt,cadòng
 vănbn
  :firstletter,:firstline
  CóthkthpviSelector khác.
 VD:
 div:firstline{fontsize:24px;fontvariant:smallcaps}
 div:firstletter{fontsize:44px;}
 Thefirstlinemustbealinewithfontsize24px,thefirst
 letterwithfontsize44pxandwhathappenswiththesecond?
15/08/2008 KhoaCNTT 24
 CácthuctínhthơngdùngCácthuctínhthơngdùng
 Kiuvănbn:
 – fontstyle:normal|italic|oblique
 – fontweight:normal| bold |bolder|lighter|100|...
 – textdecoration:none|underline|overline
 – textalign:left|right|center|justify
 – color
 – fontfamily
 – lineheight
 – margin:toprightleftbottom
15/08/2008 KhoaCNTT 25
 CácthuctínhthơngdùngCácthuctínhthơngdùng
 – backgroundattachment:fixed |scoll
 – backgroundcolor:white/Hex:#ffffffhoctransparent
 – backgroundimage:
 – backgroundposition:
 – backgroundrepeat:repeat|repeatx|repeaty |norepeat
body 
{ body
 backgroundimage:url(images/bg.gif); {
 backgroundposition:50%50%; SCROLLBARARROWCOLOR:red;
 backgroundrepeat:norepeat; SCROLLBARBASECOLOR:white;
 backgroundcolor:black; }
} 
 15/08/2008 KhoaCNTT 26
 Bàitp1Bàitp1
 DùngCSSñvittrangwebnhưsauvicácmàuca
 tngtiêuñkhácnhau:
15/08/2008 KhoaCNTT 27
 Bàitp2Bàitp2
 DùngfileCSSbênngoàiñvittrangnhusau:
15/08/2008 KhoaCNTT 28
 Bàitp3Bàitp3
 Khôngdùngbng,dùngdanhsáchUL,CSSñto
 trangwebvimenunhưhìnhsau.
 – Màunn:purple
 – Màukhidichutvào:#FF3300
15/08/2008 KhoaCNTT 29
ul
{
 float:left; 
 width:100%; 
 padding:0; Linkone
 margin:0; Linktwo
 liststyletype:none; Linkthree
} Linkfour
li{display:inline}
a
{
 float:left; 
 width:6em; Noidungtrongtrangchuduoctrinh
 textdecoration:none; bayoday
 color:white; 
 backgroundcolor:purple;
 padding:0.2em0.6em; 
 borderright:1pxsolidwhite; 
}
a:hover{backgroundcolor:#ff3300}
15/08/2008 KhoaCNTT 30
15/08/2008 KhoaCNTT 31

File đính kèm:

  • pdfBảng kiểu CSS.pdf
Tài liệu liên quan