CSS PDF
CSS PDF
net )
1
CSS for starter , written by saturngod ( www.saturngod.net )
Comment! 8
Selector! 8
ID Selector! 8
Class Selector! 9
Background Color! 13
Background Image! 15
Text Color! 25
Text alignment! 25
Text Transformation! 25
Text Indentation! 26
Word Spacing! 29
Nowrap! 30
2
CSS for starter , written by saturngod ( www.saturngod.net )
Vertical Align! 30
Text-shadow! 31
Fonts! 34
Font Family! 34
Font Style! 35
Font Size! 35
Font Bold! 37
Font Variant! 38
Font Properties! 39
Style Link! 41
Text Decoration! 42
background color! 42
Lists! 43
Image List! 46
Shorthand property! 48
CSS Tables! 50
Tables Borders! 50
Collapse Borders! 51
Table Padding! 58
Table Color! 60
3
CSS for starter , written by saturngod ( www.saturngod.net )
CSS Border! 67
Border Style! 67
border-style values:! 67
Border Width! 69
Border Color! 71
CSS Outline! 77
CSS Margin! 78
CSS Padding! 80
Nesting Selectors! 84
CSS Dimension! 84
Position! 90
Fixed Position! 90
Relative Position! 91
Absolute Position! 93
Z-Index! 96
CSS Floating! 98
Opacity! 108
4
CSS for starter , written by saturngod ( www.saturngod.net )
5
CSS for starter , written by saturngod ( www.saturngod.net )
6
CSS for starter , written by saturngod ( www.saturngod.net )
color:blue; font-size:12px;
<html>
<head>
<title>CSS</title>
<style type="text/css">
p { color: red;}
</style>
</head>
<p>Hi! I am red.</p>
7
CSS for starter , written by saturngod ( www.saturngod.net )
</html>
CSS ေရးမယ္ဆိုရင္ <style> နဲ႕ စျပီး </style> နဲ႕ ဆံုးတဲ့ ၾကားထဲမွာ ေရးရပါတယ္။
အမ်ားအားျဖင့္ေတာ့ <head> နဲ႕ </head> ၾကားထဲမွာ ေရးရပါတယ္။
Comment
/* This is comment */
Selector
အေပၚမွာ ကၽြန္ေတာ္ ေျပာခဲ့ဘူးပါတယ္။ Selector အေၾကာင္းပါ။ Select မွာ HTML element
ေတြ ျဖစ္တဲ့ p , h3 စတာေတြ သံုးလို႕ရသလို id နဲ႕class ကိုလည္း သံုးလို႕ရပါတယ္။ HTML
attribute မွာ id နဲ႕class ဆိုတာ ရိွပါတယ္။
ID Selector
<html>
<head>
<title>CSS</title>
8
CSS for starter , written by saturngod ( www.saturngod.net )
<style type="text/css">
#red_id { color: red;}
</style>
</head>
<p id="red_id">Hi! I am red id.</p>
<p >Hi! I am normal.</p>
</html>
Class Selector
<html>
<head>
<title>CSS</title>
<style type="text/css">
.red_class { color: red;}
</style>
</head>
<p class="red_class">Hi! I am red class.</p>
<p> Hi! I am normal.</p>
9
CSS for starter , written by saturngod ( www.saturngod.net )
<html>
<head>
<title>CSS</title>
<style type="text/css">
h3.red_class { color: red;}
</style>
</head>
<h3 class="red_class">Hi I am H3</h3>
<p class="red_class">Hi! I am red id.</p>
<p> Hi! I am normal.</p>
<p class="red_class">Hi! I am red id.</p>
</html>
10
CSS for starter , written by saturngod ( www.saturngod.net )
11
CSS for starter , written by saturngod ( www.saturngod.net )
<head>
<link rel="stylesheet" type="text/css" href="external.css">
</head>
external.css ကေတာ့ သီးသန္႕ file ပါ။ file path ေတြကိုေတာ့ HTML တုန္းက ေျပာခဲ့ျပီးပါျပီ။
image path ေတြ ေခၚတဲ့ေနရာမွာတုန္းက ရွင္းျပခဲ့ပါတယ္။ external.css ကိုလည္း အဲလို
ေခၚတာပါပဲ။
တစ္ျခား ဘာမွ မပါပဲ css ေတြ ခ်ေရးထားရံုပါပဲ။ တျခား html tag ေတြ ထည့္စရာလည္း
မလုိပါဘူး။
12
CSS for starter , written by saturngod ( www.saturngod.net )
CSS Background
Background ကို မေျပာခင္ background နဲ႕ လုပ္ထားတဲ့ CSS ေလးကို ျပပါတယ္။
အဲဒါက CSS background image နဲ႕ CSS backround color ကို သံုးထားတာပါ။ သာမာန္
HTML နဲ႕ အဲလိုမ်ဳိး ဖန္တီးလို႕ မရပါဘူး။
Background Color
<html>
<head>
<title>Back ground</title>
<style type="text/css">
body {background-color:#b0c4de;}
</style>
</head>
<body>
13
CSS for starter , written by saturngod ( www.saturngod.net )
</body>
</html>
<html>
<head>
<title>Back ground</title>
<style type="text/css">
h1 {background-color:#6495ed;}
p {background-color:#e0ffff;}
div {background-color:#b0c4de;}
</style>
</head>
<body>
<h1>Header</h1>
<div>
This is DIV Layer using background-color.
<br/>
<p>This is paragraph using background-color.</p>
</div>
</body>
</html>
Background Image
<html>
<head>
<style type="text/css">
body {background-image:url('paper.gif');}
</style>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>
15
CSS for starter , written by saturngod ( www.saturngod.net )
16
CSS for starter , written by saturngod ( www.saturngod.net )
<html>
<head>
<style type="text/css">
body
{
background-image:url('gradient2.png');
background-repeat:repeat-x;
}
</style>
</head>
<body>
<h1>Hello World!</h1>
</body>
17
CSS for starter , written by saturngod ( www.saturngod.net )
</html>
<html>
18
CSS for starter , written by saturngod ( www.saturngod.net )
<head>
<style type="text/css">
body
{
background-image:url('img_tree.png');
background-repeat:no-repeat;
}
</style>
</head>
<body>
<h1>Hello World!</h1>
<p>W3Schools background image example.</p>
<p>The background image is only showing once, but it is disturbing
the reader!</p>
</body>
</html>
19
CSS for starter , written by saturngod ( www.saturngod.net )
<style type="text/css">
body
{
background-image:url('img_tree.png');
background-repeat:no-repeat;
background-position:top right;
margin-right:200px;
}
</style>
</head>
20
CSS for starter , written by saturngod ( www.saturngod.net )
လို႕ေရးထားတာ အေပၚက code နဲ႕ အတူတူပါပဲ။ background ဆိုတဲ့ property မွာ ေအာက္က
property ေတြေပါင္းျပီး ေရးလို႕ရပါတယ္။
• background-color
• background-image
• background-repeat
• background-attachment
21
CSS for starter , written by saturngod ( www.saturngod.net )
• background-position
<html>
<head>
<style type="text/css">
body
{
background-image:url('smiley.gif');
background-repeat:no-repeat;
}
</style>
</head>
<body>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>The background-image is fixed. Try to scroll down the page.</p>
</body>
</html>
22
CSS for starter , written by saturngod ( www.saturngod.net )
<style type="text/css">
body
{
background-image:url('smiley.gif');
background-repeat:no-repeat;
background-attachment:fixed;
}
</style>
23
CSS for starter , written by saturngod ( www.saturngod.net )
24
CSS for starter , written by saturngod ( www.saturngod.net )
Text Color
text color ကိုေတာ့ CSS မွာ color လို႕သံုးပါတယ္။ ေအာက္မွာ ဥပမာ ၾကည့္ပါ။
body { color:#FF0000; }
Text alignment
p { text-align: center; }
h1 { text-align: right; }
h2 { text-align : justify }
Text Transformation
ကၽြန္ေတာ္တုိ႕ေတြ HTML မွာ upper case ေတြ lower case ေတြေျပာင္းခ်င္ရင္ စာေတြ
ျပန္ျပင္ရိုက္ရပါတယ္။ CSS သံုးရင္ အဲလို ျပန္ျပင္ရိုက္တဲ့ ျပႆနာ ရွင္းသြားပါတယ္။ ေအာက္က
example ေလး ကို ၾကည့္ၾကည့္ပါ။
<html>
<head>
<title>Sample</title>
<style type="text/css">
25
CSS for starter , written by saturngod ( www.saturngod.net )
p.uppercase {text-transform:uppercase;}
p.lowercase {text-transform:lowercase;}
p.capitalize {text-transform:capitalize;}
</style>
<body>
<p class="uppercase">uppder case</p>
<p class="lowercase">LOWER CASE</p>
<p class="capitalize">capitalize</p>
</body>
</head>
</html>
Text Indentation
<html>
<head>
<title>Sample</title>
<style type="text/css">
p {text-indent:50px;}
</style>
<body>
<p>
Testing Testing Testing Testing Testing Testing Testing Testing
Testing Testing Testing Testing Testing Testing Testing Testing
26
CSS for starter , written by saturngod ( www.saturngod.net )
<html>
<head>
<style type="text/css">
h1 {letter-spacing:2px;}
h2 {letter-spacing:-3px;}
</style>
</head>
<body>
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
</body>
</html>
<html>
<head>
<style type="text/css">
p.small {line-height:90%;}
p.big {line-height:200%;}
</style>
</head>
<body>
<p>
This is a paragraph with a standard line-height.
The default line height in most browsers is about 110% to 120%.
This is a paragraph with a standard line-height.
</p>
<p class="small">
This is a paragraph with a smaller line-height.
This is a paragraph with a smaller line-height.
This is a paragraph with a smaller line-height.
</p>
<p class="big">
This is a paragraph with a bigger line-height.
This is a paragraph with a bigger line-height.
28
CSS for starter , written by saturngod ( www.saturngod.net )
</body>
</html>
p{direction:rtl;}
Word Spacing
29
CSS for starter , written by saturngod ( www.saturngod.net )
<body>
<p>
This is some text. This is some text.
</p>
</body>
</html>
Nowrap
p
{
white-space:nowrap;
}
ကိုယ့္ဘာသာ ကိုယ္စမ္းၾကည့္လုိက္ေပါ့။
Vertical Align
<html>
<head>
<style type="text/css">
img.top {vertical-align:text-top;}
img.bottom {vertical-align:text-bottom;}
30
CSS for starter , written by saturngod ( www.saturngod.net )
</style>
</head>
<body>
<p>An <img src="w3schools_logo.gif" alt="W3Schools" width="270"
height="50" /> image with a default alignment.</p>
<p>An <img class="top" src="w3schools_logo.gif" alt="W3Schools"
width="270" height="50" /> image with a text-top alignment.</p>
<p>An <img class="bottom" src="w3schools_logo.gif" alt="W3Schools"
width="270" height="50" /> image with a text-bottom alignment.</p>
</body>
</html>
ဒီလိုေလးေပၚလိမ့္မယ္။
Text-shadow
<html>
<head>
<style>
p.test {
text-shadow: #6374AB 20px 25px 2px;
}
31
CSS for starter , written by saturngod ( www.saturngod.net )
</style>
</head>
<body>
<p class="test">This is txt shadow</p>
</body>
</html>
32
CSS for starter , written by saturngod ( www.saturngod.net )
33
CSS for starter , written by saturngod ( www.saturngod.net )
Fonts
HTML မွာတုန္းက ကၽြန္ေတာ္တုိ႕ေတြ font tag နဲ႕ စာလံုးေတြကို ေျပာင္းခဲ့တာ
မွတ္မိအံုးမယ္ထင္ပါတယ္။ CSS မွာလည္း font ေတြကို ေျပာင္းလဲလုိ႕ရပါတယ္။ font tag သံုးမယ္ဆိုရင္
ေနရာ အမ်ားၾကီးမွာ font tag ေတြ လိုက္ထည့္ေနရလိမ့္မယ္။ ဒီေတာ့ CSS class ေလး သံုးျပီး
လြယ္လြယ္ကူကူ ဖန္တီးႏုိင္ပါတယ္။
Font Family
<html>
<head>
<title>Font family</title>
<style type="text/css">
.time
{
font-family: "Times New Roman", Times, serif;
}
.arial
{
font-family: Arial,Verdana;
}
</style>
</head>
<body>
<p class="time">This is time class</p>
<p class="arial">This is arial class</p>
</body>
</html>
အဲဒါကို browser မွာ ဖြင့္လိုက္ရင္ ေအာက္ကလို ျမင္ရမယ္။ စာလံုး font မတူတာကို ေတြ႕ရမွာပါ။ ကိုယ္
အသံုးျပဳခ်င္တဲ့ font ကို font-family ထဲမွာ ေရးရံုပဲ။ font list ကို , နဲ႕ေရးရတယ္။ ေရွ႕ဆံုး font မရိွရင္
ဒုတိယ font ကို အသံုးျပဳပါတယ္။
34
CSS for starter , written by saturngod ( www.saturngod.net )
Font Style
<body>
<p class="normal">This is a paragraph, normal.</p>
<p class="italic">This is a paragraph, italic.</p>
<p class="oblique">This is a paragraph, oblique.</p>
</body>
</html>
Font Size
35
CSS for starter , written by saturngod ( www.saturngod.net )
html မွာ font size ေတြကို font tag နဲ႕ ျပင္ရပါတယ္။ CSS မွာေတာ့ လြယ္လြယ္ကူကူေလး
ျပင္လုိ႕ရတယ္။ ေအာက္က code ေလးကို ၾကည့္လုိက္ပါ။
<html>
<head>
<style type="text/css">
h1 {font-size:40px;}
h2 {font-size:30px;}
p {font-size:14px;}
</style>
</head>
<body>
</body>
</html>
36
CSS for starter , written by saturngod ( www.saturngod.net )
Internet Explorer မွာ တစ္ခါတစ္ေလ font size ေပၚတဲ့ ပံုျခင္းမတူတတ္ဘူး။ W3C ကေတာ့ px အစား
em ကို သံုးဖို႕ recommend လုပ္ထားပါတယ္။
h1 {font-size:2.5em;} /* 40px/16=2.5em */
h2 {font-size:1.875em;} /* 30px/16=1.875em */
p {font-size:0.875em;} /* 14px/16=0.875em */
Font Bold
font ေတြကို bold လုပ္ခ်င္တဲ့ အခါမွာ b tag ထည့္ေပးရပါတယ္။ တစ္ခါတည္း CSS မွာလည္း bold
လုပ္မယ္လုိ႕ ေျပာလို႕ရပါတယ္။
<html>
<head>
<style type="text/css">
p.normal {font-weight:normal;}
p.light {font-weight:lighter;}
p.thick {font-weight:bold;}
p.thicker {font-weight:900;}
</style>
</head>
<body>
<p class="normal">This is a paragraph.</p>
<p class="light">This is a paragraph.</p>
<p class="thick">This is a paragraph.</p>
<p class="thicker">This is a paragraph.</p>
</body>
</html>
37
CSS for starter , written by saturngod ( www.saturngod.net )
Font Variant
<html>
<head>
<style type="text/css">
p.normal {font-variant:normal;}
p.small {font-variant:small-caps;}
</style>
</head>
<body>
<p class="normal">My name is Hege Refsnes.</p>
<p class="small">My name is Hege Refsnes.</p>
</body>
</html>
38
CSS for starter , written by saturngod ( www.saturngod.net )
Font Properties
39
CSS for starter , written by saturngod ( www.saturngod.net )
40
CSS for starter , written by saturngod ( www.saturngod.net )
Style Link
Link ေတြကိုလည္း css ကို အသံုးျပဳလုိ႕ရပါတယ္။ ဘယ္လိုမ်ဳိးေတြလဲဆိုေတာ့ စာလံုး အေရာင္ ၊ font ၊
background စတာေတြကို ထည့္သြင္းလုိ႕ရတာေပါ့။
<html>
<head>
<style type="text/css">
a:link {color:#FF0000;} /* unvisited link */
a:visited {color:#00FF00;} /* visited link */
a:hover {color:#FF00FF;} /* mouse over link */
a:active {color:#0000FF;} /* selected link */
</style>
</head>
<head>
<a href="http://www.saturngod.net">Saturngod’s Blog</a>
</head>
</html>
41
CSS for starter , written by saturngod ( www.saturngod.net )
link နဲ႕ အဓိက တြဲသံုးလို႕ရတဲ့ style ေလးေတြ ျပသြားပါမယ္။ link ရဲ႕ selector ၄ ခုကို
နားလည္သြားရင္ css code ေတြကို စိတ္ၾကိဳက္ထည့္သြင္းေရးသားႏိုင္ပါျပီ။ စာသားအေရာင္ ေနာက္ခံ
အေရာင္ အျပင္ အေရာင္မ်ဳိးမ်ဳိး လြယ္လင့္တကူ ေရးသားႏိုင္ပါတယ္။
Text Decoration
link နဲ႕ အဓိက အသံုးမ်ားတာကေတာ့ text-decoration ပါ။ သူက ဘာလုပ္ေပးတာလဲဆိုေတာ့ link မွာ
underline ေဖ်ာက္ခ်င္တဲ့ အခါမွာ အသံုးျပဳႏိုင္ပါတယ္။
a:link {text-decoration:none;}
a:hover{text-decoration: underline}
background color
ကၽြန္ေတာ္ ေထြေထြ ထူးထူး မေျပာေတာ့ပါဘူး။ background-color နဲ႕ ပတ္သက္ျပီးေတာ့ ကၽြန္ေတာ္
အေပၚမွာ ေျပာထားခဲ့ျပီးပါျပီ။ link မွာ css က code ေတြကို လြယ္လင့္တကူ အသံုးျပဳႏိုင္ပါတယ္။
အတူူတူပါပဲ။ link မွာ အဓိက selector ၄ ခုကို အသံုးျပဳတယ္ဆိုတာကို မွတ္မိဖို႕ပဲလုိပါတယ္။
<html>
<head>
<style type="text/css">
a:link {background-color:#B2FF99;}
a:visited {background-color:#FFFF85;}
a:hover {background-color:#FF704D;}
a:active {background-color:#FF704D;}
</style>
</head>
<head>
<a href="http://www.google.com">Google</a>
</head>
</html>
42
CSS for starter , written by saturngod ( www.saturngod.net )
Lists
List ဆိုတာကေတာ့ ul နဲ႕ ol ပဲ ေပါ့။ ul က အခုေနာက္ပိုင္း CSS ေတြမွာ table အစား အသံုးျပဳလာတာ
ေတြ႕ရပါတယ္။ table အစား အသံုးျပဳတယ္ဆိုတာက ရိုးရိုး html မွာ မျဖစ္ႏိုင္သလိုပဲ။ ဒါေပမယ့္ CSS နဲ႕
ေပါင္းျပီး သံုးလိုက္တဲ့ အခါမွာေတာ့ Table လုိမ်ဳိး ဖန္တီးလာႏိုင္ပါတယ္။
<body>
<p>Example of unordered lists:</p>
<ul class="a">
<li>Coffee</li>
<li>Tea</li>
<li>Coca Cola</li>
</ul>
<ul class="b">
<li>Coffee</li>
<li>Tea</li>
<li>Coca Cola</li>
</ul>
<ol class="c">
43
CSS for starter , written by saturngod ( www.saturngod.net )
<li>Coffee</li>
<li>Tea</li>
<li>Coca Cola</li>
</ol>
<ol class="d">
<li>Coffee</li>
<li>Tea</li>
<li>Coca Cola</li>
</ol>
</body>
</html>
ပံုမွန္ HTML မွာလည္း လြယ္လင့္တကူ ဖန္တီးႏိုင္သလို css နဲ႕လည္း ဖန္တီးႏိုင္ပါတယ္။ CSS ရဲ႕
အားသာခ်က္ေတြကိုေတာ့ ကၽြန္ေတာ္ေျပာျပီးပါျပီ။ ဒါေၾကာင့္ css ကို အသံုးျပဳျပီး ေျပာင္းလဲလို႕ရတာဟာ
44
CSS for starter , written by saturngod ( www.saturngod.net )
Value Description
none No marker
circle စက္ဝုိင္း
square ေလးေထာင့္ပံ
Value Description
armenian Traditional Amenian
numbering
decimal number
lower-greek lower-greek
(alpha,beta,gamma,etc)
lower-latin lower-latin(a,b,c,d,etc)
lower-roman lower-roman(i,ii,iii,etc)
upper-latin upper-latin(A,B,C,D,etc);
45
CSS for starter , written by saturngod ( www.saturngod.net )
Image List
<html>
<head>
<style type="text/css">
ul
{
list-style-image:url('sqpurple.gif');
}
</style>
</head>
<body>
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Coca Cola</li>
</ul>
</body>
</html>
46
CSS for starter , written by saturngod ( www.saturngod.net )
<html>
<head>
<style type="text/css">
ul
{
list-style-type:none;
padding:0px;
margin:0px;
}
li
{
background-image:url(sqpurple.gif);
background-repeat:no-repeat;
background-position:0px 5px;
padding-left:14px;
}
</style>
</head>
<body>
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Coca Cola</li>
</ul>
</body>
</html>
ဒီ code က နည္းနည္းမ်ားသြားျပီ။ ul ကို list-style-type ကို none လုပ္ျပီး padding, margin ကို 0px
ေပးျပီး ညိွလိုက္တယ္။ ျပီးမွ li ကို background-image နဲ႕ ပံုထည့္ျပီး position ကို ေရႊ႕လိုက္တာေပါ့ဗ်ာ။
47
CSS for starter , written by saturngod ( www.saturngod.net )
Shorthand property
တစ္ခါတစ္ေလ လိုင္းတစ္ေၾကာင္းတည္းနဲ႕ ျပီးသြားေစခ်င္တဲ့ အခါမွာ shorthand style သံုးျပီး
ေ၇းလိုက္လို႕ရပါတယ္။
ul
{
list-style:square url("sqpurple.gif");
}
ေရးတဲ့ အခါမွာေတာ့
• list-style-type
• list-style-position
• list-style-image
48
CSS for starter , written by saturngod ( www.saturngod.net )
49
CSS for starter , written by saturngod ( www.saturngod.net )
CSS Tables
HTML table ကို CSS နဲ႕တြဲျပီး သံုးတဲ့ အခါမွာ ေအာက္ကလုိမ်ဳိး table တစ္ခု ဖန္တီးႏို္င္ပါတယ္။
Tables Borders
<html>
<head>
<style type="text/css">
table,th,td
{
border:1px solid black;
}
</style>
</head>
<body>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>
50
CSS for starter , written by saturngod ( www.saturngod.net )
<tr>
<td>Peter</td>
<td>Griffin</td>
</tr>
<tr>
<td>Lois</td>
<td>Griffin</td>
</tr>
</table>
</body>
</html>
အဲဒီ code ေလးကို run ၾကည့္လုိက္ပါ။ ေအာက္ကလို ျမင္ရပါမယ္။ CSS က border တစ္ခုပဲ
ထည့္ထားပါတယ္။ border ကိုေတာ့ ေနာက္ပိုင္းမွာ ရွင္းျပပါမယ္။ သီးသန္႕ ရွင္းျပမွျဖစ္မွာမုိ႕ပါ။
Collapse Borders
<html>
<head>
<style type="text/css">
table
{
border-collapse:collapse;
}
table, td, th
{
border:1px solid black;
}
51
CSS for starter , written by saturngod ( www.saturngod.net )
</style>
</head>
<body>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>
<tr>
<td>Peter</td>
<td>Griffin</td>
</tr>
<tr>
<td>Lois</td>
<td>Griffin</td>
</tr>
</table>
<p><b>Note:</b> If a !DOCTYPE is not specified, the border-
collapse property can produce unexpected results.</p>
</body>
</html>
border-collapse:collapse;
52
CSS for starter , written by saturngod ( www.saturngod.net )
<body>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Savings</th>
</tr>
<tr>
<td>Peter</td>
<td>Griffin</td>
<td>$100</td>
</tr>
<tr>
<td>Lois</td>
<td>Griffin</td>
<td>$150</td>
53
CSS for starter , written by saturngod ( www.saturngod.net )
</tr>
<tr>
<td>Joe</td>
<td>Swanson</td>
<td>$300</td>
</tr>
<tr>
<td>Cleveland</td>
<td>Brown</td>
<td>$250</td>
</tr>
</table>
</body>
</html>
code ေလးကေတာ့ ပံုမွန္ပါပဲ။ table ရဲ႕ width က 100% သံုးလိုက္ျပီးေတာ ့ th ရဲ႕ height ကိုေတာ့
50 px ေပးလုိက္ပါတယ္။ သာမာန္ ရိုးရွင္း တဲ့ code ေလးပါပဲ။
Text alignment မွာ vertical နဲ႕ horizontal ဆိုျပီး ၂ မ်ဳိးရိွပါတယ္။ horizontal ကေတာ့ text-align
ကိုပဲသံုးပါတယ္။ text-align မွာ left, right, center, justify ဆိုျပီး ရိွပါတယ္။ အခုေတာ့ သိသာေအာင္
text-align:right;
နဲ႕ ျပထားပါတယ္။
<html>
54
CSS for starter , written by saturngod ( www.saturngod.net )
<head>
<style type="text/css">
table,td,th
{
border:1px solid black;
}
td
{
text-align:right;
}
</style>
</head>
<body>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Savings</th>
</tr>
<tr>
<td>Peter</td>
<td>Griffin</td>
<td>$100</td>
</tr>
<tr>
<td>Lois</td>
<td>Griffin</td>
<td>$150</td>
</tr>
<tr>
<td>Joe</td>
<td>Swanson</td>
<td>$300</td>
</tr>
<tr>
<td>Cleveland</td>
55
CSS for starter , written by saturngod ( www.saturngod.net )
<td>Brown</td>
<td>$250</td>
</tr>
</table>
</body>
</html>
vertical align ကေတာ့ top , bottom , middle ဆိုျပီး ရိွပါတယ္။ တခ်က္ေလာက္ code ေလးကို
ၾကည့္လုိက္ရေအာင္
td
{
height:50px;
vertical-align:bottom;
}
ကိုပဲ သံုးထားတယ္။
<html>
<head>
<style type="text/css">
table,td,th
{
border:1px solid black;
56
CSS for starter , written by saturngod ( www.saturngod.net )
}
td
{
text-align:right;
}
</style>
</head>
<body>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Savings</th>
</tr>
<tr>
<td>Peter</td>
<td>Griffin</td>
<td>$100</td>
</tr>
<tr>
<td>Lois</td>
<td>Griffin</td>
<td>$150</td>
</tr>
<tr>
<td>Joe</td>
<td>Swanson</td>
<td>$300</td>
</tr>
<tr>
<td>Cleveland</td>
<td>Brown</td>
<td>$250</td>
</tr>
</table>
</body>
57
CSS for starter , written by saturngod ( www.saturngod.net )
</html>
Table Padding
table မွာ padding က အေရးၾကီးပါတယ္။ padding က ဘာလဲဆိုတာကိုေတာ့ HTML table အခန္းမွာ
ျပန္လည္ ဖတ္ရႈႏိုင္ပါတယ္။ ရွင္းေအာင္ ေျပာရရင္ေတာ့ padding က border နဲ႕ စာ အကြာအေဝးလို႕
ဆိုရပါလိမ့္မယ္။
padding အတြက္ကေတာ့
td
{
padding:15px;
}
<html>
58
CSS for starter , written by saturngod ( www.saturngod.net )
<head>
<style type="text/css">
table, td, th
{
border:1px solid black;
}
td
{
padding:15px;
}
</style>
</head>
<body>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Savings</th>
</tr>
<tr>
<td>Peter</td>
<td>Griffin</td>
<td>$100</td>
</tr>
<tr>
<td>Lois</td>
<td>Griffin</td>
<td>$150</td>
</tr>
<tr>
<td>Joe</td>
<td>Swanson</td>
<td>$300</td>
</tr>
<tr>
<td>Cleveland</td>
59
CSS for starter , written by saturngod ( www.saturngod.net )
<td>Brown</td>
<td>$250</td>
</tr>
</table>
</body>
</html>
Table Color
table မွာ ေနာက္ထပ္ လွပ ေအာင္ျပင္ရမယ့္ အပိုင္းကေတာ့ color ပါပဲ။ color ဆိုတဲ့အထဲမွာ border
color နဲ႕ background color ဆုိျပီး ရိွပါတယ္။ border အေၾကာင္းကိုေတာ့ basic css style ေတြ
ျပီးသြားျပီး box Model အပိုင္းမွာ ရွင္းျပေပးပါ့မယ္။
table, td, th
{
border:1px solid green;
}
60
CSS for starter , written by saturngod ( www.saturngod.net )
th
{
background-color:green;
color:white;
}
<html>
<head>
<style type="text/css">
table, td, th
{
border:1px solid green;
border-collapse:collapse;
padding:5px;
}
th
{
background-color:green;
color:white;
}
</style>
</head>
<body>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Savings</th>
</tr>
<tr>
<td>Peter</td>
<td>Griffin</td>
<td>$100</td>
</tr>
<tr>
61
CSS for starter , written by saturngod ( www.saturngod.net )
<td>Lois</td>
<td>Griffin</td>
<td>$150</td>
</tr>
<tr>
<td>Joe</td>
<td>Swanson</td>
<td>$300</td>
</tr>
<tr>
<td>Cleveland</td>
<td>Brown</td>
<td>$250</td>
</tr>
</table>
</body>
</html>
ပံုမွန္ table နဲ႕ လံုးဝကို မတူေတာ့ပါဘူး။ ကၽြန္ေတာ္တို႕ code ကို နည္းနည္းေလး ျပန္ျပင္ရေအာင္။
တစ္ေၾကာင္းျပီးတိုင္း အေရာင္ေလးေတြ ေျပာင္းသြားေအာင္ေပါ့။
tr.alt
{
background-color:#D5FFC8;
}
62
CSS for starter , written by saturngod ( www.saturngod.net )
<html>
<head>
<style type="text/css">
table, td, th
{
border:1px solid green;
border-collapse:collapse;
padding:5px;
}
tr.alt
{
background-color:#D5FFC8;
}
th
{
background-color:green;
color:white;
}
</style>
</head>
<body>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Savings</th>
</tr>
<tr>
<td>Peter</td>
<td>Griffin</td>
<td>$100</td>
</tr>
63
CSS for starter , written by saturngod ( www.saturngod.net )
<tr class='alt'>
<td>Lois</td>
<td>Griffin</td>
<td>$150</td>
</tr>
<tr>
<td>Joe</td>
<td>Swanson</td>
<td>$300</td>
</tr>
<tr class='alt'>
<td>Cleveland</td>
<td>Brown</td>
<td>$250</td>
</tr>
</table>
</body>
</html>
ဆိုျပီး ျမင္ရပါလိမ့္မယ္။
64
CSS for starter , written by saturngod ( www.saturngod.net )
<html>
<head>
<style type="text/css">
div.ex
65
CSS for starter , written by saturngod ( www.saturngod.net )
{
width:220px;
padding:10px;
border:5px solid gray;
margin:0px;
}
</style>
</head>
<body>
<img src="250px.gif" width="250" height="1" /><br /><br />
</body>
</html>
66
CSS for starter , written by saturngod ( www.saturngod.net )
CSS Border
ကဲ... table အခန္းကတည္းက ပါလာတဲ့ border အေၾကာင္း အခု ရွင္းပါျပီ။ border ဆိုတာ
ဘာလဲဆိုတာကေတာ့ ေထြေထြထူးထူး ရွင္းဖို႕ မလိုေတာ့ပါဘူး။
Border Style
Border style ကေတာ့ border ကို ဘယ္လိုမ်ဳိး ပံုလဲဆိုတာအတြက္ေပါ့။ border style မွာ solid
border ကိုေတာ့ အေရွ႕မွာ သံုးခဲ့ပါတယ္။
border-style values:
value ေတြက dotted, dashed , solid, double, grrove , ridge , inset, outset ေတြပါ။
ပံုေတြကေတာ့ ေအာက္ကလို ျမင္ရပါတယ္။
67
CSS for starter , written by saturngod ( www.saturngod.net )
<html>
<head>
<style type="text/css">
p.none {border-style:none;}
p.dotted {border-style:dotted;}
p.dashed {border-style:dashed;}
p.solid {border-style:solid;}
p.double {border-style:double;}
p.groove {border-style:groove;}
p.ridge {border-style:ridge;}
p.inset {border-style:inset;}
p.outset {border-style:outset;}
p.hidden {border-style:hidden;}
</style>
</head>
<body>
<p class="none">No border.</p>
<p class="dotted">A dotted border.</p>
<p class="dashed">A dashed border.</p>
<p class="solid">A solid border.</p>
<p class="double">A double border.</p>
<p class="groove">A groove border.</p>
68
CSS for starter , written by saturngod ( www.saturngod.net )
Border Width
<html>
<head>
<style type="text/css">
p.one
{
border-style:solid;
69
CSS for starter , written by saturngod ( www.saturngod.net )
border-width:5px;
}
p.two
{
border-style:solid;
border-width:medium;
}
p.three
{
border-style:solid;
border-width:1px;
}
</style>
</head>
<body>
<p class="one">Some text.</p>
<p class="two">Some text.</p>
<p class="three">Some text.</p>
<p><b>Note:</b> The "border-width" property does not work if it is
used alone. Use the "border-style" property to set the borders
first.</p>
</body>
</html>
70
CSS for starter , written by saturngod ( www.saturngod.net )
Border Color
border color ကေတာ့ border ရဲ႕ အေရာင္ေတြေပါ့။ HTML မွာ အေရာင္သံုးတဲ့ ကိစၥကို ကၽြန္ေတာ္
ေရးခဲ့ဖူးပါတယ္။ name သို႕မဟုတ္ #RRGGBB နဲ႕ အသံုျပဳပါတယ္။ CSS မွာေတာ့ rgb(0,0,255) လိုမ်ဳိး
အသံုးျပဳလို႕ရပါေသးတယ္။
<html>
<head>
<style type="text/css">
p.one
{
border-style:solid;
border-color:red;
}
p.two
{
border-style:solid;
border-color:#98bf21;
}
</style>
</head>
<body>
<p class="one">A solid red border</p>
<p class="two">A solid green border</p>
71
CSS for starter , written by saturngod ( www.saturngod.net )
left လား right လား top လား bottom လား စျပီး အေသးစိတ္ကို အသံုးျပဳလို႕ရေအာင္လည္း CSS မွာ
ေရးသားႏိုင္ပါတယ္။ တစ္ခါတစ္ေလ ညာဘက္မွာ border style တစ္မ်ဳိး ေျပာင္းျပီး ေဖာ္ျပခ်င္တဲ့
အခါမ်ဳိးမွာေပါ့
p
{
border-top-style:dotted;
border-right-style:solid;
border-bottom-style:dotted;
border-left-style:solid;
}
<html>
<head>
<style type="text/css">
p
{
72
CSS for starter , written by saturngod ( www.saturngod.net )
border-top-style:dotted;
border-right-style:solid;
border-bottom-style:dotted;
border-left-style:solid;
}
</style>
</head>
<body>
<p>2 different border styles.</p>
</body>
</html>
ဘယ္လိုမ်ဳိး ေပၚမလဲဆိုရင္ေတာ့
border-style:dotted solid;
73
CSS for starter , written by saturngod ( www.saturngod.net )
border-style: dotted;
ဆိုျပီး ေရးလုိ႕ရပါတယ္။
property ကေတာ့
border-width
border-style
border-color
ဆိုျပီး အသံုးျပဳပါတယ္။
74
CSS for starter , written by saturngod ( www.saturngod.net )
75
CSS for starter , written by saturngod ( www.saturngod.net )
76
CSS for starter , written by saturngod ( www.saturngod.net )
CSS Outline
outline ကေတာ့ link ေတြထည့္လိုက္တဲ့အခါ ပံုေတြ ၊ စာေတြရဲ႕ ပတ္လည္မွာ dotted line
ေလး ကို ေျပာတာပါ။ သူ႕ကို border နဲ႕ မွားတတ္ပါတယ္။ ေသခ်ာေအာင္ ေအာက္က example
ေလးကို ၾကည့္လုိက္ပါ။
<html>
<head>
<style type="text/css">
p
{
border:1px solid red;
outline:green dotted thick;
}
</style>
</head>
<body>
<p><b>Note:</b> IE8 supports the outline properties only if a !
DOCTYPE is
specified.</p>
</body>
</html>
outline ကိုေတာ့
ဆိုျပီး အသံုးျပဳပါတယ္။
CSS Margin
CSS မွာ margin နဲ႕ padding ပိုင္းက အေရးၾကီးပါတယ္။ margin နဲ႕ padding ကို အစပိုင္းမွာ
ေရာေထြးေနတတ္ပါတယ္။ သို႕ေပမယ့္ margin နဲ႕ padding က လံုးဝ ကြာျခားပါတယ္။ ဒီ
အေၾကာင္းကို HTML မွာတုန္းက ကၽြန္ေတာ္ ေျပာခဲ့ျပီးပါျပီ။ margin ကို ေအာက္ကလို မ်ဳိး
အသံုးျပဳပါတယ္။
လို႕ ဆိုတာပါ။
လုိ႕ ဆိုတာပါ။
margin:25px 50px;
ပါ။
78
CSS for starter , written by saturngod ( www.saturngod.net )
margin:25px;
လို႕ဆိုပါတယ္။
<html>
<head>
<style type="text/css">
p
{
background-color:yellow;
}
p.margin
{
margin:100px 50px;
}
</style>
</head>
<body>
<p>This is a paragraph with no specified margins.</p>
<p class="margin">This is a paragraph with specified margins.</p>
</body>
</html>
79
CSS for starter , written by saturngod ( www.saturngod.net )
top နဲ႕ bottom က 100px ျဖစ္ျပီး left နဲ႕ right က 50px ကြာထားတာကို ေတြ႕ႏိုင္ပါတယ္။
margin က အျပင္ကေန အကြာအေဝးပါ။ padding ကေတာ့ အတြင္း အကြာအေဝးေပါ့။
ေနာက္ျပီး တစ္ခု ျခင္းဆီ အေနနဲ႕ ခြဲေရးလည္းရပါတယ္။
margin-top:100px;
margin-bottom:100px;
margin-right:50px;
margin-left:50px;
margin top က 100 px , bottom ကလည္း 100px , left နဲ႕ right ကေတာ့ 50 px ဆိုျပီး
တစ္ခုျခင္းဆီ ေရးသားထားတာပါ။
CSS Padding
padding ကလည္း margin လိုမ်ဳိးပါပဲ။ သူကေတာ့ အတြင္းကေန အကြာအေဝးပါ။ သူ႕
အသံုးျပဳပံုကလည္း margin အတိုင္းပါပဲ။
လို႕ ဆိုတာပါ။
လုိ႕ ဆိုတာပါ။
padding:25px 50px;
ပါ။
padding:25px;
လို႕ဆိုပါတယ္။
padding-top:25px;
padding-bottom:25px;
padding-right:50px;
padding-left:50px;
<html>
<head>
<style type="text/css">
p
{
background-color:yellow;
81
CSS for starter , written by saturngod ( www.saturngod.net )
}
p.padding
{
padding-top:25px;
padding-bottom:25px;
padding-right:50px;
padding-left:50px;
}
</style>
</head>
<body>
<p>This is a paragraph with no specified padding.</p>
<p class="padding">This is a paragraph with specified paddings.</
p>
</body>
</html>
82
CSS for starter , written by saturngod ( www.saturngod.net )
h1
{
color:green;
}
h2
{
color:green;
}
p
{
color:green;
}
လို႕ ေရးထားတာကို
h1,h2,p
{
color:green;
}
83
CSS for starter , written by saturngod ( www.saturngod.net )
Nesting Selectors
p
{
color:blue;
text-align:center;
}
.marked
{
background-color:blue;
}
.marked p
{
color:white;
}
CSS Dimension
CSS မွာ အရြယ္အစားေတြ ကို သတ္မွတ္ဖို႕ ေအာက္က properties ေတြကို
အသံုးျပဳႏိုင္ပါတယ္။
84
CSS for starter , written by saturngod ( www.saturngod.net )
min-width အနည္းဆံုးထားရမည့္
အက်ယ္ျဖစ္သည္။
<html>
<head>
<style type="text/css">
85
CSS for starter , written by saturngod ( www.saturngod.net )
a:hover {visibility:hidden;}
</style>
</head>
<body>
<a href="http://www.saturngod.net">hover and hide</a>
</body>
</html>
ကို run တဲ့ အခါမွာ hover and hide ဆိုတာ ေပၚလာပါမယ္။ အဲဒီ ေပၚ mouse တင္လုိက္ရင္
စာ ေပ်ာက္သြားတာ ေတြ႕ရမွာပါ။
<html>
<head>
<style type="text/css">
h1.hidden {display:none;}
</style>
</head>
<body>
<h1>This is a visible heading1</h1>
<h1 class="hidden">This is a hidden heading 2</h1>
<p>Notice that the hidden heading does not take up space.</p>
</body>
</html>
86
CSS for starter , written by saturngod ( www.saturngod.net )
Block နဲ႕ Inline ကိုေတာ့ list ေတြနဲ႕ တြဲသံုးၾကပါတယ္။ list နဲ႕ တြဲသံုးျပမွသာ block နဲ႕ inline
ကို နားလည္ပါလိမ့္မယ္။ block ကေတာ့ block တစ္ခုလံုး အျပည့္ယူသြားတာပါ။ inline ကေတာ့
တစ္ေနရာတည္းမွာ တစ္ေၾကာင္းတည္း အေနနဲ႕ ေဖာ္ျပေပးမွာပါ။ ဥပမာ။။ menu ေတြ
လိုမ်ဳိးေပါ့။
<html>
<head>
<style type="text/css">
li{display:inline;}
</style>
</head>
<body>
<ul>
<li><a href="/html/default.asp" target="_blank">HTML</a></li>
<li><a href="/css/default.asp" target="_blank">CSS</a></li>
<li><a href="/js/default.asp" target="_blank">JavaScript</a></li>
<li><a href="/xml/default.asp" target="_blank">XML</a></li>
</ul>
</body>
</html>
87
CSS for starter , written by saturngod ( www.saturngod.net )
HTML မွာ တုန္းက တစ္ေၾကာင္းတည္းမွာ အသံုးျပဳခ်င္လုိ႕ div အစား span ကို သံုးခဲ့တာ
မွတ္မိအံုးမယ္ ထင္ပါတယ္။ span ကို div လိုမ်ဳိး line breaking ျဖစ္သြားေအာင္ display:block
နဲ႕ ဖန္တီးလို႕ရပါတယ္။
<html>
<head>
<style type="text/css">
span
{
display:block;
}
</style>
</head>
<body>
<h2>Nirvana</h2>
<span>Record: MTV Unplugged in New York</span>
<span>Year: 1993</span>
<h2>Radiohead</h2>
<span>Record: OK Computer</span>
<span>Year: 1997</span>
</body>
</html>
88
CSS for starter , written by saturngod ( www.saturngod.net )
89
CSS for starter , written by saturngod ( www.saturngod.net )
Position
CSS မွာ position က အေရးပါတဲ့ အထဲမွာ ပါပါတယ္။ Position မွာ fixed , relative , absolute
ဆိုတာေတြ ရိွပါတယ္။
Fixed Position
<html>
<head>
<style type="text/css">
p.pos_fixed
{
position:fixed;
top:10px;
right:5px;
}
p.pos_fixed2
{
position:fixed;
bottom:5px;
left:5px;
background:#453245;
color:#FFF;
}
</style>
</head>
<body>
90
CSS for starter , written by saturngod ( www.saturngod.net )
Relative Position
Relative position ကေတာ့ လက္ရိွ ရိွေနတဲ့ position ေပၚမွာ မူတည္ျပီး ေျပာင္းလဲ ေပးတာပါ။
ေအာက္က ဥပမာ ေလးကို ၾကည့္ၾကည့္လုိက္ပါ။ သူက position absolute နဲ႕ အျမဲ
ေရာေထြးတတ္ပါတယ္။
<html>
91
CSS for starter , written by saturngod ( www.saturngod.net )
<head>
<style type="text/css">
h2.pos_left
{
position:relative;
top:-40px;
}
</style>
</head>
<body>
<h2>This is a heading with no position</h2>
<h2 class="pos_left">This heading is moved left according to its
normal position</h2>
</html>
92
CSS for starter , written by saturngod ( www.saturngod.net )
Absolute Position
<html>
<head>
<style type="text/css">
h2
{
position:absolute;
left:100px;
top:150px;
}
</style>
</head>
<body>
<h2>This is a heading with an absolute position</h2>
<p>With absolute positioning, an element can be placed anywhere on
a page. The heading below is placed 100px from the left of the
page and 150px from the top of the page.</p>
</body>
</html>
93
CSS for starter , written by saturngod ( www.saturngod.net )
<html>
<head>
<style type="text/css">
h2.abs
{
position:absolute;
left:100px;
top:0px;
}
h2.abs2 {
position:absolute;
top:0px;
right:0px;
}
div.relative {
color:#FFF;
background:#000;
position:relative;
height:200px;
}
</style>
</head>
<body>
94
CSS for starter , written by saturngod ( www.saturngod.net )
<div>
<h2 class="abs">This is header</h2>
</div>
<div class="relative">
Sample Text
<h2 class="abs2">This is header</h2>
</div>
</html>
position ကို absolute ထားလိုက္တဲ့ အခါမွာ browser ေပၚက ၾကိဳက္တဲ့ ေနရာကို ေရႊ႕လို႕ရပါတယ္။
သို႕ေပမယ့္ menu ေတြ တည္ေဆာက္တဲ့အခါမွာ ျဖစ္ျဖစ္ layout ခ်တဲ့ ေနရာ မွာ ျဖစ္ျဖစ္ div layer
ထဲက ၾကိဳက္တဲ့ ေနရာကို ပဲ ေရႊ႕ခ်င္တဲ့အခါမွာ div ကို position: relative ဆိုျပီး ေၾကျငာထားရပါမယ္။
95
CSS for starter , written by saturngod ( www.saturngod.net )
Z-Index
<html>
<head>
<style type="text/css">
div.below,div.upper {
position:absolute;
top:100px;
left:100px;
}
div.below {
background:#0F0;
z-index:1;
}
div.upper {
background:#F00;
left:130px;
z-index:10;
}
</style>
</head>
<body>
<div class="upper">
Sample
</div>
<div class="below">
Sample
</div>
</body>
</html>
96
CSS for starter , written by saturngod ( www.saturngod.net )
97
CSS for starter , written by saturngod ( www.saturngod.net )
CSS Floating
CSS Floating ဆုိတာက ဘယ္ဘက္ ကပ္မလား ညာဘက္ကမလားဆုိျပီး သတ္မွတ္ေပးတာပါ။
position absolute နဲ႕ မတူတာက သူက လက္ရိွ ရိွေနတဲ့ ေနရာကေန ညာဘက္ သြားကပ္တာပါ။
ေအာက္က code ေလးကို ၾကည့္ျပီး run ၾကည့္လုိက္ပါ။
<html>
<head>
<style type="text/css">
img
{
float:right;
}
</style>
</head>
<body>
<p>In the paragraph below, we have added an image with style
<b>float:right</b>. The result is that the image will float to the
right in the paragraph.</p>
<p>
<img src="logocss.gif" width="95" height="84" />
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
</p>
</body>
</html>
98
CSS for starter , written by saturngod ( www.saturngod.net )
အခုေတာ့ float ကို သံုးျပီး gallery ေလး လုပ္ၾကည့္ရေအာင္။ ပံုမွန္ အားျဖင့္ img ေတြကို ေရးလိုက္ရင္
တစ္လိုင္းဆင္းျပီးေတာ့ ေပၚေနပါလိမ့္မယ္။ ဒါေၾကာင့္ float:left ဆိုျပီး အကုန္လံုးကို တစ္လိုင္းထဲ
ေပၚေအာင္ ဖန္တီးလုိက္ပါမယ္။ float left က display:inline နဲ႕ မတူတာကေတာ့ screen width
ျပည့္သြားရင္ သူ႕အလိုလို ေနာက္တစ္လိုင္း ေျပာင္းသြားေပးတာပါ။
<html>
<head>
<style type="text/css">
.thumbnail
{
float:left;
width:110px;
height:90px;
margin:5px;
}
</style>
</head>
<body>
<h3>Image Gallery</h3>
99
CSS for starter , written by saturngod ( www.saturngod.net )
<p>Try resizing the window to see what happens when the images
does not have enough room.</p>
<img class="thumbnail" src="klematis_small.jpg" width="107"
height="90">
<img class="thumbnail" src="klematis2_small.jpg" width="107"
height="80">
<img class="thumbnail" src="klematis3_small.jpg" width="116"
height="90">
<img class="thumbnail" src="klematis4_small.jpg" width="120"
height="90">
<img class="thumbnail" src="klematis_small.jpg" width="107"
height="90">
<img class="thumbnail" src="klematis2_small.jpg" width="107"
height="80">
<img class="thumbnail" src="klematis3_small.jpg" width="116"
height="90">
<img class="thumbnail" src="klematis4_small.jpg" width="120"
height="90">
</body>
</html>
100
CSS for starter , written by saturngod ( www.saturngod.net )
<html>
<head>
<style type="text/css">
.thumbnail
{
float:left;
width:110px;
height:90px;
margin:5px;
}
.text_line
{
clear:both;
margin-bottom:2px;
}
</style>
</head>
<body>
<h3>Image Gallery</h3>
<p>Try resizing the window to see what happens when the images
does not have enough room.</p>
<img class="thumbnail" src="klematis_small.jpg" width="107"
height="90">
<img class="thumbnail" src="klematis2_small.jpg" width="107"
height="80">
<img class="thumbnail" src="klematis3_small.jpg" width="116"
height="90">
<img class="thumbnail" src="klematis4_small.jpg" width="120"
height="90">
<h3 class="text_line">Second row</h3>
<img class="thumbnail" src="klematis_small.jpg" width="107"
height="90">
101
CSS for starter , written by saturngod ( www.saturngod.net )
102
CSS for starter , written by saturngod ( www.saturngod.net )
103
CSS for starter , written by saturngod ( www.saturngod.net )
First Child
first-child pseudo class ကေတာ့ ပထမဆံုး child ကို ေခၚတာပါ။ ရွင္းသြားေအာင္ code ေလးကို
ၾကည့္လုိက္ပါ။
<html>
<head>
<style type="text/css">
p:first-child
{
color:blue;
}
</style>
</head>
<body>
<p>This is some text.</p>
<p>This is some text.</p>
<p><b>Note:</b> For :first-child to work in IE8 and earlier, a
DOCTYPE must be declared.</p>
</body>
</html>
104
CSS for starter , written by saturngod ( www.saturngod.net )
<html>
<head>
<style type="text/css">
p > i:first-child
{
color:blue;
}
</style>
</head>
<body>
<p>I am a <i>strong</i> man. I am a <i>strong</i> man.</p>
<p>I am a <i>strong</i> man. I am a <i>strong</i> man.</p>
<p><b>Note:</b> For :first-child to work in IE8 and earlier, a
DOCTYPE must be declared.</p>
</body>
</html>
p>i ဆိုတာကေတာ့ p ေအာက္မွာ ရိွတဲ့ i ကို ဆိုလိုတာပါ။ p:first-child i ဆုိရင္ေတာ့ ပထမဆံုး p ရဲ႕ i
ကို ပဲ ေျပာင္းပါလိမ့္မယ္။ အဲဒါကိုေတာ့ ကိုယ္တိုင္ စမ္းၾကည့္လုိက္ပါ။
105
CSS for starter , written by saturngod ( www.saturngod.net )
:before နဲ႕ :after selector ေတြက content နဲ႕ တြဲျပီး အသံုးျပဳပါတယ္။ စာနဲ႕ ရွင္းျပေနရင္ နည္းနည္း
ရႈပ္ပါတယ္။ code ေလးကို ၾကည့္လုိက္ပါ။
<html>
<head>
<style type="text/css">
p.no1:before {
content:"Hello";
background:#000;
color:#FFF;
}
p.no2:after {
content:"good bye";
background:#000;
color:#FFF;
}
</style>
</head>
<body>
<p class="no1">
This is sample text
</p>
<p class="no2">
This is sample text
</p>
</body>
</html>
106
CSS for starter , written by saturngod ( www.saturngod.net )
107
CSS for starter , written by saturngod ( www.saturngod.net )
Opacity
ပံုေတြ background color ေတြကို ေဖ်ာက္ျပီး ျမင္ရေအာင္ အတြက္ opacity ကို ေလ်ာ့ခ်ေပးရပါတယ္။
ေအာက္က code ေလးကို ေလ့လာၾကည့္ပါ။
<html>
<head>
<style type="text/css">
body {
background:#000;
}
div {
background:#F00;
opacity:0.5;
color:#FFF;
}
</style>
</head>
<body>
<div>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Nullam velit nisl, aliquet vitae egestas a, fringilla quis arcu.
Sed pulvinar nunc et tortor lacinia sed elementum arcu ultricies.
Integer non dolor dolor. Vivamus lobortis sem ut nibh mattis
interdum. Proin tristique rhoncus erat vitae mollis. Ut vulputate
adipiscing nibh, sit amet imperdiet nisi adipiscing ac. Aliquam
lacinia odio quis ipsum semper aliquet. Fusce aliquet ligula
felis, non euismod enim. Quisque viverra, diam non fringilla
commodo, nisi tortor dignissim dolor, sed lacinia ante dolor sed
elit. Maecenas adipiscing purus nec urna molestie et vehicula elit
iaculis. Mauris eget elit bibendum nibh mattis sollicitudin
tristique ac purus. Vestibulum ante ipsum primis in faucibus orci
luctus et ultrices posuere cubilia Curae; Ut ultrices egestas
quam, sit amet pellentesque augue hendrerit eu.
</div>
108
CSS for starter , written by saturngod ( www.saturngod.net )
</body>
</html>
<html>
<head>
<style type="text/css">
body {
background:url('pattern.gif');
}
div {
background:rgba(255,0,0,0.5);
color:#FFF;
}
109
CSS for starter , written by saturngod ( www.saturngod.net )
</style>
</head>
<body>
<div>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Nullam velit nisl, aliquet vitae egestas a, fringilla quis arcu.
Sed pulvinar nunc et tortor lacinia sed elementum arcu ultricies.
Integer non dolor dolor. Vivamus lobortis sem ut nibh mattis
interdum. Proin tristique rhoncus erat vitae mollis. Ut vulputate
adipiscing nibh, sit amet imperdiet nisi adipiscing ac. Aliquam
lacinia odio quis ipsum semper aliquet. Fusce aliquet ligula
felis, non euismod enim. Quisque viverra, diam non fringilla
commodo, nisi tortor dignissim dolor, sed lacinia ante dolor sed
elit. Maecenas adipiscing purus nec urna molestie et vehicula elit
iaculis. Mauris eget elit bibendum nibh mattis sollicitudin
tristique ac purus. Vestibulum ante ipsum primis in faucibus orci
luctus et ultrices posuere cubilia Curae; Ut ultrices egestas
quam, sit amet pellentesque augue hendrerit eu.
</div>
</body>
</html>
Image Sprite
image sprite ဆိုတာကေတာ့ ပံုေတြ အမ်ားၾကီးထဲကို ပံု တစ္ပံုထဲမွာ ထည့္ထားတာပါ။ အဲဒီ
အတြက္ေၾကာင့္ ပံု ေတြ အမ်ားၾကီးအတြက္ တစ္ခါပဲ request လုပ္ရံုပါပဲ။ ျပီးမွ ပံုေတြကို ခြဲ ျပီးေတာ့
ျပန္သံုးတာေပါ့။
<html>
<head>
<style type="text/css">
img.home
{
width:46px;
height:44px;
background:url(img_navsprites.gif) 0 0;
}
img.next
{
width:43px;
height:44px;
background:url(img_navsprites.gif) -91px 0;
}
</style>
</head>
<body>
<img class="home" src="img_trans.gif" width="1" height="1" />
<br /><br />
111
CSS for starter , written by saturngod ( www.saturngod.net )
<html>
<head>
<style type="text/css">
#navlist{position:relative;}
#navlist li{margin:0;padding:0;list-
style:none;position:absolute;top:0;}
#navlist li, #navlist a{height:44px;display:block;}
#home{left:0px;width:46px;}
#home{background:url('img_navsprites.gif') 0 0;}
#prev{left:63px;width:43px;}
#prev{background:url('img_navsprites.gif') -47px 0;}
#next{left:129px;width:43px;}
#next{background:url('img_navsprites.gif') -91px 0;}
</style>
112
CSS for starter , written by saturngod ( www.saturngod.net )
</head>
<body>
<ul id="navlist">
<li id="home"><a href="default.html"></a></li>
<li id="prev"><a href="css_intro.html"></a></li>
<li id="next"><a href="css_syntax.html"></a></li>
</ul>
</body>
</html>
ကၽြန္ေတာ္တို႕က row တစ္ခု တည္းျဖစ္ေနတဲ့အတြက္ top ကို 0px နဲ႕ ပဲ ေခၚေနပါတယ္။ တကယ္လို႕
ကၽြန္ေတာ္တုိ႕ေတြ hover effect ေတြ သံုးခ်င္တဲ့အခါမွာ row ၂ ခုကို အသံုးျပဳရင္ ရသလို ၁ ခု
တည္းမွာလည္း ရပါတယ္။ အခု top position အေၾကာင္း သိသြားေအာင္ ေအာက္က ပံုကို
အသံုးျပဳပါမယ္။
<html>
<head>
<style type="text/css">
#navlist{position:relative;}
#navlist li{margin:0;padding:0;list-
style:none;position:absolute;top:0;}
113
CSS for starter , written by saturngod ( www.saturngod.net )
#home{left:0px;width:46px;}
#home{background:url('img_navsprites_hover.gif') 0 0;}
#home a:hover{background: url('img_navsprites_hover.gif') 0
-45px;}
#prev{left:63px;width:43px;}
#prev{background:url('img_navsprites_hover.gif') -47px 0;}
#prev a:hover{background: url('img_navsprites_hover.gif') -47px
-45px;}
#next{left:129px;width:43px;}
#next{background:url('img_navsprites_hover.gif') -91px 0;}
#next a:hover{background: url('img_navsprites_hover.gif') -91px
-45px;}
</style>
</head>
<body>
<ul id="navlist">
<li id="home"><a href="default.html"></a></li>
<li id="prev"><a href="css_intro.html"></a></li>
<li id="next"><a href="css_syntax.html"></a></li>
</ul>
</body>
</html>
အေပၚက code မွာ hover effect အတြက္ top ေတြကို -45px ကို သံုးထားတာကို ေတြ႕ႏိုင္ပါတယ္။
114
CSS for starter , written by saturngod ( www.saturngod.net )
Attribute Selector
တစ္ခါတစ္ေလမွာ selector ေတြကို attribute နဲ႕ အသံုးျပဳဖို႕ လိုပါတယ္။ ဥပမာ input လိုမ်ဳိးေပါ့။ input
ရဲ႕ type ေတြမွာ textbox , password , checkbox , file , submit , image စတာေတြ ရိွတဲ့အခါမွာ
textbox ေတြ အကုန္လံုးကိုပဲ select လုပ္ခ်င္တယ္။ အဲဒီ အခါမ်ဳိးမွာ attribute selector ကို
အသံုးျပဳႏိုင္ပါတယ္။
<html>
<head>
<style type="text/css">
input[type="text"] {
background:#F00;
color:#FFF;
}
</style>
</head>
<body>
<input type="text" value="Text" />
<input type="password" value="password" />
</body>
</html>
[attribute_name=attribute_value]
115
CSS for starter , written by saturngod ( www.saturngod.net )
What Next ?
HTML နဲ႕ CSS ကို ေလ့လာျပီးတဲ့အခါမွာေတာ့ ထပ္ျပီးေတာ့ javascript , jquery တို႕ကို
ေလ့လာသင့္ပါတယ္။ အခု ကၽြန္ေတာ္ ေရးထားခဲ့တဲ့ စာအုပ္ က HTML 4 နဲ႕ CSS 2 ပဲ ရိွပါေသးတယ္။
ဒါေၾကာင့္ HTML 5 နဲ႕ CSS 3 ကို လည္း ေလ့လာသင့္ပါတယ္။ HTML 5 နဲ႕ CSS 3 မွာ
ပိုမိုေကာင္းမြန္တဲ့ feature ေတြ အေျမာက္အျမား ပါဝင္ပါတယ္။ javascript , jquery တုိ႕ကို
တတ္ကြ်မ္းထားတဲ့ အခါမွာ HTML , CSS တို႕နဲ႕ တည္ေဆာက္တဲ့ website ထက္ပို ျပီးေကာင္းမြန္
ေအာင္ လုပ္လုိ႕ရလာပါတယ္။ ဒါေၾကာင့္ စာအုပ္ဖတ္ျပီးသြားတဲ့ အခါမွာ ရပ္မေနပဲ အသစ္သစ္ေတြကို
ထပ္မံေလ့လာျပီး လွပ ေကာင္းမြန္တဲ့ web site ေတြ တည္ေဆာက္ႏုိင္ၾကပါေစဗ်ာ။
116