HTML Styles - CSS
- CSS ကို Cascading Style Sheets လို့ အရှည် ခေါ် ပါတယ်။
- CSSက multiple web pages တွေရဲ့ layoutတွေကို တစ်ကြိမ်တည်းနဲ့ ထိန်းချုပ်နိုင်ပါတယ်။
CSSဆိုတာ ဘာလဲ?
CSSက web pageတစ်ခုရဲ့ layout တွေ ပုံစံချတဲ့အခါ အသုံးဝင်ပါတယ်။သင်တို့က အရောင်တွေ ၊ စာလုံးတွေ ၊ စာလုံးတွေရဲ့ အရွယ်အစား ၊ element တစ်ခုနဲ့တစ်ခုကြား အကွာအဝေး ၊ element တွေကို ဘယ်လိုပုံစံ ထားမလဲ ၊ ဘယ်background image (သို့မဟုတ် background colorကို သုံးမယ်၊ မတူညီတဲ့ device တွေအတွက် ပုံစံအမျိုးမျိုး ချတာတွေ ၊ အတွက်ဆို CSSကို သုံးပြီး ထိန်းချုပ်နိုင်ပါတယ်။
Cascading ဆိုတဲ့အဓိပ္ပါယ် ဆိုတာက parent element ကိုသက်ရောက်တဲ့ styleတစ်ခုက အဲ့ဒီ parentအတွင်းမှာ ရှိတဲ့ children elementတွေကို အကျိုးသက်ရောက်စေပါတယ်။ ဆိုလိုရင်းကတော့ သင်ဟာ bodyရဲ့ text ကို အပြာရောင် သတ်မှတ်လိုက်ရင် bodyအတွင်းမှာ ရှိတဲ့ headings ၊ paragraphs၊ အခြား element တွေကပါ အပြာရောင် ကို သက်ရောက်ပါလိမ့်မယ်။
CSSအသုံးပြုခြင်း
CSS ကို HTML Document ထဲသို့ နည်း၃ နည်း ဖြင့် ထည့်နိုင်ပါတယ်။
- Inline -style attribute ကို HTML elements အတွင်းမှာ ထည့်ပြီး အသုံးပြုခြင်း။
- Internal-style element ကို < head > section အတွင်းမှာ ထည့်ပြီး အသုံးပြုခြင်း။
- External - external css fileကို < link > element ကိုသုံး၍ချိတ်ပြီး အသုံးပြုခြင်း။
ဒီTutorial ထဲမှာ ကျွန်ပ်တို့က inline နဲ့ internal style ကို သုံးလိမ့်မယ်။ ဘာလို့လဲဆိုတော့ ဖော်ပြရတာ လွယ်ကူပြီး try it yourself အသုံးပြုဖို့လည်း သင့်အတွက် လွယ်ကူစေသောကြောင့်ဖြစ်ပါတယ်။
Internal CSS
HTML element တစ်ခုဆို styleတစ်ခု နဲ့ သက်ရောက်ရန်အတွက် inline CSSကို အသုံးပြုပါတယ်။
အောက်ပါ example ကတော့ < h1 > element ရဲ့ စာလုံး အရောင်ကို အပြာရောင်ပေးပြီးတော့ < p > element အတွက်တော့ အနီရောင် ပေးထားပါတယ်။
Example
< p style="color:red;" > A red paragraph. < /p >
Internal CSS
Internal CSSကို HTML pageရဲ့ head section အတွင်းမှာ style element ကိုသုံးပြီး သတ်မှတ်ပါတယ်။
အောက်ပါ exampleကတော့ < h1 > element တွေရဲ့ စာလုံး အရောင်တွေကို အပြာရောင် သတ်မှတ်ပြီး < p > element တွေရဲ့ စာလုံးအရောင်တွေကို အနီရောင် သတ်မှတ်ထားပါတယ်။
Example
< html >
< head >
< style >
body {background-color: powderblue;}
h1{color: blue;}
p{color: red;}
< /style >
< /head >
< body >
< h1>This is a heading < /h1 >
< p>This is a paragraph.< /p >
< /body >
< /html >
External CSS
External CSSကိုတော့ HTML pagesတွေ အတွက် < style > ကိုသတ်မှတ်ပြီး အသုံးပြုနိုင်ပါတယ်။
External style sheet ကို အသုံးပြုရန် HTML pageတစ်ခုစီ ရဲ့ < head > section အတွင်းမှာ < link > တစ်ခု ကို ထည့်ရပါတယ်။
Example
< html >
< head >
< link rel="stylesheet" href="styles.css" >
< /head >
< body >
< h1 >This is a heading < /h1 >
< p>This is a paragraph.< /p >
< /body >
< /html >
External CSSကို မည်သည့် text editor မှာမဆို ရေးနိုင်ပါတယ်။အဲ့ဒီ fileကို. css ဆိုတဲ့ file extension နဲ့ saveနိုင်ပါတယ်။
"styles.css"ဆိုတာ...
"styles.css":
}
h1 {
color: blue;
}
p {
color: red;
}
external cssအတွင်းမှာ, file တစ်ခုကို ပြောင်းလဲခြင်းဖြင့် web siteရဲ့ ပုံစံကို ပြောင်းနိင်ပါတယ်။
CSS Colors, Fonts and Sizes
ဒီမှာ ကျွန်ပ်တို့က CSS properties အချို့ကို သုံးထားသော elements အချိူ့ကို ဖော်ပြလိမ့်မယ်။ ဒါတွေနဲ့ ပတ်သတ်ပြီး နောက်ထပ်ပိုပြီး သင့်ယူနိုင်လိမ့်မယ်။
စာလုံးတွေရဲ့ အရောင်အတွက် CSS color property နဲ့ သတ်မှတ်ပါတယ်။စာလုံးတွေအတွက် CSSရဲ့ font-family property နဲ့ သတ်မှတ်ပါတယ်စာလုံးတွေရဲ့ အရွယ်အစားအတွက် CSSရဲ့ font-size property နဲ့ သတ်မှတ်ပါတယ်။
Example
Use of CSS color, font-family and font-size properties:
< html >
< head >
< style >
h1 {
color: blue;
font-family: verdana;
font-size: 300%;
}
p {
color: red;
font-family: courier;
font-size: 160%;
} < /style >
< /head >
< body >
< h1 > This is a heading < /h1 >
< p > This is a paragraph.< /p >
< /body >
< /html >
CSS Border
HTML element တစ်ခုကို ဘောင်ခတ်ချင်ရင် CSSရဲ့ border property နဲ့ သတ်မှတ်ပါတယ်။
CSS Padding
Web pageရဲ့ ဘောင်နဲ့ web pageအတွင်းရှိ စာလုံးကြား အကွာအဝေးကို padding property နဲ့ သတ်မှတ်ပါတယ်။
Example
Use of CSS border and padding properties:
border: 2px solid blue;
padding: 30px; }
CSS Margin
Web pageရဲ့ ဘောင်နဲ့ ဘောင်အပြင်ဘက် အကွာအဝေးကို marginနဲ့ သတ်မှတ်ပါတယ်။
Example
Use of CSS border and margin properties:
border: 2px solid blue;
margin: 50px;
}
Link to External CSS
URL အပြည့်အစုံ (သို့မဟုတ်) လက်ရှိ web pageနဲ့ ဆက်စပ်တဲ့ css file လမ်းကြောင်းနဲ့ external cssကို ညွန်းနိုင်ပါတယ်။
Example
This example uses a full URL to link to a style sheet:
Example
This example links to a style sheet located in the html folder on the current web site:
Example
This example links to a style sheet located in the html folder on the current web site:
Chapter Summary
ဒီexampleကတော့ style sheet တစ်ခုကို full urlနဲ့ linkချိတ်ရန် သုံးထားပါတယ်။လက်ရှိ web site ပေါ် က html folder ထဲက style sheet ကို linkချိတ်ထားပါတယ်။ဒီexampleကတော့ folderတူ အတွင်းမှာရှိတဲ့ style sheet ကို linkချိတ်ထားပါတယ်။Inline styleအတွက် HTML ရဲ့ style attribute ကို သုံးပါတယ်။Intern CSS ကို သတ်မှတ်ရန် HTMLရဲ့ style elementကို သုံးပါတယ်။External CSS fileကို ညွန်းရန်အတွက် HTMLရဲ့ link element ကို သုံးပါတယိ။Style နဲ့ link elementsတွေကို သိမ်းရန် head element ကို သုံးပါတယ်။စာလုံးတွေရဲ့ အရောင်အတွက် CSSရဲ့ color property ကိုသုံးပါတယ်စာလုံးတွေရဲ့ ပုံစံအတွက် CSSရဲ့ font-family property ကို သုံးပါတယ်။စာလုံးတွေရဲ့ အရွယ်အစား အတွက် CSSရဲ့ font-size property ကိုသုံးပါတယ်။ဘောင်ခတ်ရန်အတွက် CSSရဲ့ border property ကိုသုံးပါတယ်။Web pageရဲ့ ဘောင်အတွင်းရှိ အကွာအဝေးအတွက် CSSရဲ့ padding property ကို သုံးပါတယ်။Web pageရဲ့ ဘောင်အပြင်ဘက် အကွာအဝေး အတွက် CSSရဲ့ margin property ကိုသုံးပါတယ်။
HTML Style Tags
| Tag | ဖော်ပြချက် |
| < style > | HTML document တစ်ခုအတွက် style. information နဲ့ သတ်မှတ်ပါတယ်။ |
| < link > | External resourceနဲ့ Document တစ်ခုကြား linkတစ်ခုလို့ သတ်မှတ်ပါတယ်။ |
No comments:
Post a Comment