CSS နောက်ခံအရွယ်အစား ပိုင်ဆိုင်မှု
ဥပမာ
"အော်တို" နှင့် ပစ်ဇယ်များဖြင့် နောက်ခံပုံ၏ အရွယ်အစားကို သတ်မှတ်ပါ-
#example1 {
background: url(mountain.jpg);
background-repeat: no-repeat;
background-size: auto;
}
#example2 {
background: url(mountain.jpg);
background-repeat:
no-repeat;
background-size: 300px 100px;
}
အောက်တွင် နောက်ထပ် "စမ်းသုံးကြည့်ပါ" ဥပမာများ။
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
background-size
ပိုင်ဆိုင်မှုသည် နောက်ခံပုံများ၏ အရွယ်အစားကို သတ်မှတ်ပေးသည် ။
ဤပိုင်ဆိုင်မှုတွင် သင်သုံးနိုင်သော မတူညီသော syntax လေးခုရှိသည်- အဓိကစကားလုံးအထားအသို ("အော်တို"၊ "ကာဗာ" နှင့် "contain")၊ တစ်ခုတည်းသောတန်ဖိုးအထားအသို (ပုံ၏အကျယ်ကိုသတ်မှတ်သည် (အမြင့်သည် "အော်တို" ဖြစ်လာသည်)၊ နှစ်ခုတန်ဖိုး အထားအသို (ပထမတန်ဖိုး- ပုံ၏ အကျယ်၊ ဒုတိယတန်ဖိုး- အမြင့်)၊ နှင့် များစွာသော နောက်ခံအစီအမံ (ကော်မာဖြင့် ပိုင်းခြားထားသည်)။
မူလတန်ဖိုး: | အော်တို |
---|---|
အမွေဆက်ခံသည်- | မဟုတ်ဘူး |
သက်ဝင်လှုပ်ရှားနိုင်သော | ဟုတ်တယ် ကာတွန်း အကြောင်းဖတ်ပါ။ |
ဗားရှင်း- | CSS3 |
JavaScript syntax- | အရာဝတ္ထု .style.backgroundSize="60px 120px" |
Browser ပံ့ပိုးမှု
ဇယားရှိ နံပါတ်များသည် ပိုင်ဆိုင်မှုကို အပြည့်အဝထောက်ခံသည့် ပထမဆုံးဘရောက်ဆာဗားရှင်းကို သတ်မှတ်ပေးသည်။
-webkit-၊ -moz- သို့မဟုတ် -o- ဖြင့်လိုက်သောနံပါတ်များသည် ရှေ့ဆက်တွဲတစ်ခုနှင့်အလုပ်လုပ်သော ပထမဆုံးဗားရှင်းကို သတ်မှတ်ပေးသည်။
Property | |||||
---|---|---|---|---|---|
background-size | 4.0 1.0 -webkit- |
9.0 | 4.0 3.6 -moz- |
4.1 3.0 -webkit- |
10.5 10.0 -o- |
CSS Syntax
background-size: auto|length|cover|contain|initial|inherit;
အိမ်ခြံမြေတန်ဖိုးများ
Value | Description | Play it |
---|---|---|
auto | Default value. The background image is displayed in its original size | |
length | Sets the width and height of the background image. The first value sets the width, the second value sets the height. If only one value is given, the second is set to "auto". Read about length units | |
percentage | Sets the width and height of the background image in percent of the parent element. The first value sets the width, the second value sets the height. If only one value is given, the second is set to "auto" | |
cover | Resize the background image to cover the entire container, even if it has to stretch the image or cut a little bit off one of the edges | |
contain | Resize the background image to make sure the image is fully visible | |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
နောက်ထပ် ဥပမာများ
ဥပမာ
ရာခိုင်နှုန်းဖြင့် နောက်ခံပုံတစ်ခု၏ အရွယ်အစားကို သတ်မှတ်ပါ-
#example1 {
background: url(mountain.jpg);
background-repeat: no-repeat;
background-size: 100%
100%;
}
#example2 {
background: url(mountain.jpg);
background-repeat: no-repeat;
background-size: 75%
50%;
}
ဥပမာ
"ကာဗာ" ဖြင့် နောက်ခံပုံ၏ အရွယ်အစားကို သတ်မှတ်ပါ-
#example1 {
background: url(mountain.jpg);
background-repeat: no-repeat;
background-size: cover;
}
ဥပမာ
"contain" ဖြင့် နောက်ခံပုံတစ်ခု၏ အရွယ်အစားကို သတ်မှတ်ပါ-
#example1 {
background: url(mountain.jpg);
background-repeat: no-repeat;
background-size:
contain;
}
ဥပမာ
ဤတွင် ကျွန်ုပ်တို့တွင် နောက်ခံပုံနှစ်ပုံရှိသည်။ ကျွန်ုပ်တို့သည် "contain" ဖြင့် ပထမနောက်ခံပုံ၏ အရွယ်အစားနှင့် ဒုတိယနောက်ခံပုံအား "cover" ဖြင့် သတ်မှတ်သည်-
#example1 {
background: url(img_tree.gif), url(mountain.jpg);
background-repeat: no-repeat;
background-size:
contain, cover;
}
ဥပမာ
"သူရဲကောင်း" ရုပ်ပုံဖန်တီးရန် မတူညီသော နောက်ခံဂုဏ်သတ္တိများကို အသုံးပြုပါ-
.hero-image {
background-image: url("photographer.jpg"); /* The
image used */
background-color: #cccccc; /* Used if the image is
unavailable */
height: 500px; /* You must set a specified height */
background-position: center; /* Center the image */
background-repeat: no-repeat; /* Do not repeat the image */
background-size: cover; /* Resize the background image to cover the entire container */
}
ဆက်စပ်စာမျက်နှာများ
CSS သင်ခန်းစာ- CSS နောက်ခံ များ
HTML DOM ရည်ညွှန်းချက်- နောက်ခံအရွယ်အစား ပိုင်ဆိုင်မှု