css background properties များကို Element တွေအတွက်နောက်ခံ effect တွေထည့်ဖို့သုံးတယ်။
In these chapters, you will learn about the following CSS background properties:
- background-color
- background-image
- background-repeat
- background-attachment
- background-position
- background (shorthand property)
CSS background-color
Background-color property က element တစ်ခုရဲ့နောက်ခံအရောင်ကိုသတ်မှတ်ပါတယ်။
Example
The background color of a page is set like this:
- body{
background-color: lightblue;- }
Other Element
HTML element တွေအတွက်နောက်ခံအရောင်ကိုသတ်မှတ်နိုင်ပါတယ်။
Example
ဒီမှာ < h1 >, <p >နှင့် <div> element တွေမှာနောက်ခံအရောင်တွေကွဲပြားပါလိမ့်မယ်။
- h1{
background-color: greens;- }
- div{
background-color: lightblue;- }
- p{
background-color:yellow;- }
Opacity / Transparency
opacity property က element တစ်ခုရဲ့ opacity / transparent ကိုသတ်မှတ်ပါတယ်။ ၀.၀ မှ ၁.၀ အတွင်းတန်ဖိုးတစ်ခုယူနိုင်သည်
မှတ်ချက်။ ။ Opacity property ကို element ရဲ့နောက်ခံမှာပွင့်လင်းမြင်သာမှုရှိစေရန်အသုံးပြုတဲ့အခါသူ့ရဲ့ element အားလုံးဟာတူညီတဲ့ပွင့်လင်းမြင်သာမှုကိုအမွေခံရသည်။ ၎င်းသည်ပွင့်လင်းမြင်သာသော element တစ်ခုအတွင်းရှိစာသားကိုဖတ်ရန်ခက်ခဲစေသည်။
Transparency using RGBA
သင်သည် element တွေကို opacity လျှောက်ထားချင်လျှင်, RGBA အရောင်တန်ဖိုးများကိုသုံးပါ။ အောက်ပါဥပမာသည်စာသားမဟုတ်ဘဲနောက်ခံအရောင်အတွက် opacity ကိုသတ်မှတ်သည်။
ကျွန်တော်တို့ရဲ့အရောင်တန်ဖိုးအနေနဲ့ RGB ကိုသုံးနိုင်သည်ကိုကျွန်ုပ်တို့၏ CSS အရောင်များအခန်းမှသင်လေ့လာသိရှိခဲ့ရသည်။ RGB အပြင်အရောင်တစ်ခုအတွက် opacity ကိုသတ်မှတ်ထားတဲ့ alpha channel (RGBA) နဲ့ RGB အရောင်တန်ဖိုးကိုသင်အသုံးပြုနိုင်တယ်။
RGBA အရောင်တန်ဖိုးကို rgba (အနီရောင်၊ အစိမ်း၊ အပြာ၊ alpha) နဲ့သတ်မှတ်ပါတယ်။ alpha parameter သည် ၀.၀ (အပြည့်အဝပွင့်လင်းမြင်သာမှု) နှင့် ၁.၀ (လုံးဝ opaque) အကြားကိန်းတစ်ခုဖြစ်သည်။
Example
The background color of a page is set like this:
- body{
background: rgba(0, 128, 0, 0.3); /* Green background with 30% opacity */- }
CSS Multiple Backgrounds
ဒီအခန်းမှာနောက်ခံပုံများစွာကို element တစ်ခုထဲထည့်ဖို့ဘယ်လိုလေ့လာရမလဲဆိုတာကိုလေ့လာပါလိမ့်မယ်။
- backgroun-size
- backgroun-origin
- background-clip
CSS Multiple Backgrounds
CSS သည် Background-image property မှတဆင့် element တစ်ခုအတွက်နောက်ခံပုံများစွာကိုသင်ခွင့်ပြုသည်။
မတူညီသောနောက်ခံပုံများကိုကော်မာများဖြင့်ခွဲခြားထားသည်။
မတူညီသောနောက်ခံပုံများကိုကော်မာများဖြင့်ခွဲခြားထားပြီးပထမပုံရိပ်သည်ကြည့်ရှုသူနှင့်အနီးဆုံးရှိသည့်တစ်ခုချင်းစီအပေါ်တွင်ပုံဖော်ထားသည်။
Example
- #example1{
background-image : url(img_flwr.gif) , url(paper.gif);background-position : right bottom, left top;background-repeat : no-repeat, repeat;- }
အောက်ဖော်ပြပါဥပမာသည် Background shorthand property ကိုသုံးသည်။
Example
- #example1{
background : url(img_flwr.gif) right bottom no-repeat , url(paper.gif) left top repeat ;- }
CSS Background Size
CSS background-size property ကနောက်ခံပုံအရွယ်အစားကိုသတ်မှတ်နိုင်သည်။
အရွယ်အစားကိုအရှည်၊ ရာခိုင်နှုန်း၊ သို့မဟုတ် (contain or cover) နှစ်ခုကိုသုံးနိုင်သည်။
Lorem Ipsum Dolor
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.
Example
- #div1{
background-image : url(img_flwr.gif) ;background-size: 100px 80px;background-repeat : no-repeat, repeat;- }
contain or cover တန်ဖိုးများ ကိုအသုံးပြုပုံ။
Example
- #div1{
background-image : url(img_flwr.gif) ;background-size: contain;background-repeat : no-repeat;- }
- #div2{
background-image : url(img_flwr.gif) ;background-size: cover;background-repeat : no-repeat;- }
Background-size property ရဲ့ value များကို(ကော်မာခွဲထားပြီး) တန်ဖိုးများစွာကိုလက်ခံသည်။
အောက်ဖော်ပြပါဥပမာသည်ပုံတစ်ပုံချင်းစီအတွက်နောက်ခံအရွယ်အစားနှင့်ကွဲပြားသောနောက်ခံပုံ (၃) ခုရှိသည်။
Example
- #example1{
background : url(img_tree.gif) left top no-repeat , url(img_flwr.gif) right bottom no-repeat ,url(paper.gif) left top repeat;background-size : 50px , 130px , auto ;- }
Full Size Background Image
ယခုတွင်ကျွန်ုပ်တို့သည် browser ၀ င်းဒိုးတစ်ခုလုံးကိုအချိန်မရွေးဖုံးကွယ်ထားသော website တစ်ခုတွင်နောက်ခံပုံရိပ်တစ်ခုထားလိုသည်။
လိုအပ်ချက်များမှာအောက်ပါအတိုင်းဖြစ်သည် -
- စာမျက်နှာတစ်ခုလုံးကိုပုံနှင့်ဖြည့်ပါ (အဖြူရောင်နေရာမရှိအောင်)
- လိုအပ်သည့်အတိုင်းပုံရိပ်ထည့်ပါ။
- စာမျက်နှာပေါ်တွင် Center ပုံရိပ်
- Scrollbars မဖြစ်ပေါ်စေပါနှင့်
အောက်ဖော်ပြပါဥပမာသည်မည်သို့ပြုလုပ်ရမည်ကိုပြသည်။ <html> element ကိုသုံးပါ (<html> element ကအမြဲတမ်း browser window ရဲ့အမြင့်ဖြစ်တယ်။ ) ထို့နောက်၎င်းကိုပုံသေဗဟိုပြုနောက်ခံထားပါ။ ထို့နောက်၎င်း၏အရွယ်အစားကို background-size property ဖြင့်ချိန်ညှိပါ။
Example
- html{
background : url(img_man.jpg) no-repeat center fixed ;background-size : cover ;- }
Hero Image
You could also use different background properties on a <div> to create a hero image (a large image with text), and place it where you want.
Example
- .hero-image{
background : url(img_man.jpg) no-repeat center ;background-size : cover ;height: 500px ;position: relative ;- }
CSS background-origin Property
နောက်ခံပုံတည်နေရာကို CSS background-origin property ကသတ်မှတ်ပါတယ်။
ဒီ property ကတန်ဖိုး ၃ မျိုးကိုယူတယ်။
- border-box - နောက်ခံပုံက border ဘယ်ဘက်အပေါ်ထောင့်ကနေစတယ်
- padding-box - နောက်ခံပုံဟာ padding edge ရဲ့ဘယ်ဘက်အပေါ်ထောင့်ကနေစတယ်
- content-box - နောက်ခံပုံဟာအကြောင်းအရာရဲ့ဘယ်ဘက်အပေါ်ထောင့်ကနေစတယ်
အောက်ပါဥပမာသည်နောက်ခံမူလပိုင်ဆိုင်မှုကိုဖော်ပြသည်။
Example
- #example1{
border : 10px solid black ;padding : 35px ;background : url(img_flwr.gif);background-repeat: no-repeat ;background-origin : content-box ;- }
CSS background-clip Property
နောက်ခံပုံတည်နေရာကို CSS background-origin property ကသတ်မှတ်ပါတယ်။
ဒီ property ကတန်ဖိုး ၃ မျိုးကိုယူတယ်။
- border-box - (default) နောက်ခံအား border ၏အပြင်ဘက်အစွန်းကစတယ်
- padding-box - နောက်ခံ padding ရဲ့အပြင်ဘက်အစွန်းကစတယ်
- content-box - နောက်ခံပုံကို content box ထဲကနေစတယ်
အောက်ပါဥပမာသည်နောက်ခံမူလပိုင်ဆိုင်မှုကိုဖော်ပြသည်။
Example
- #example1{
border : 10px solid black ;padding : 35px ;background : yellow ;background-origin : content-box ;- }
CSS Advanced Background Properties
| Property | Description |
| background-clip | Specifies the painting area of the background |
| background-image | Specifies one or more background images for an element |
| background-origin | Specifies where the background image(s) is/are positioned |
| background-size | Specifies the size of the background image(s) |
No comments:
Post a Comment