CSS ကျူတိုရီရယ်

CSS ပင်မစာမျက်နှာ CSS နိဒါန်း CSS Syntax CSS ရွေးချယ်မှုများ CSS လုပ်နည်း CSS မှတ်ချက်များ CSS အရောင်များ CSS နောက်ခံများ CSS နယ်နိမိတ်များ CSS အနားသတ်များ CSS Padding CSS အမြင့်/အနံ CSS Box မော်ဒယ် CSS အကြမ်းဖျင်း CSS စာသား CSS ဖောင့်များ CSS အိုင်ကွန်များ CSS လင့်ခ်များ CSS စာရင်းများ CSS ဇယားများ CSS Display CSS Max-အကျယ် CSS ရာထူး CSS Z အညွှန်း CSS Overflow CSS Float CSS Inline-block CSS ကို ချိန်ညှိပါ။ CSS Combinators CSS Pseudo-class CSS Pseudo-ဒြပ်စင် CSS Opacity CSS Navigation Bar CSS Dropdowns CSS ရုပ်ပုံပြခန်း CSS Image Sprites CSS Attr ရွေးချယ်မှုများ CSS ပုံစံများ CSS ကောင်တာများ CSS ဝဘ်ဆိုဒ် အပြင်အဆင် CSS ယူနစ်များ CSS တိကျမှု CSS !အရေးကြီးသည်။ CSS သင်္ချာလုပ်ဆောင်ချက်များ

CSS အဆင့်မြင့်

CSS Rounded Corners CSS Border ပုံများ CSS နောက်ခံများ CSS အရောင်များ CSS အရောင်သော့ချက်စာလုံးများ CSS Gradients CSS Shadows CSS စာသားအကျိုးသက်ရောက်မှုများ CSS ဝဘ်ဖောင့်များ CSS 2D အသွင်ပြောင်းမှုများ CSS 3D အသွင်ပြောင်းမှုများ CSS အသွင်ကူးပြောင်းမှုများ CSS Animations CSS Tooltips CSS စတိုင်ပုံများ CSS Image Reflection CSS object-fit CSS object-position CSS Masking CSS ခလုတ်များ CSS Pagination CSS ကော်လံမျိုးစုံ CSS User Interface CSS အပြောင်းအလဲများ CSS Box Sizing CSS မီဒီယာမေးခွန်းများ CSS MQ နမူနာများ CSS Flexbox

CSS တုံ့ပြန်မှု

RWD မိတ်ဆက် RWD Viewport RWD Grid View RWD မီဒီယာမေးခွန်းများ RWD ပုံများ RWD ဗီဒီယိုများ RWD မူဘောင်များ RWD နမူနာများ

CSS Grid

Grid Intro ဂရစ်ကွန်တိန်နာ ဇယားကွက်

CSS SASS

SASS ကျူတိုရီရယ်

CSS နမူနာများ

CSS Templates များ CSS နမူနာများ css စာမေးပွဲ CSS လေ့ကျင့်ခန်းများ CSS လက်မှတ်

CSS ကိုးကားချက်များ

CSS အကိုးအကား CSS ရွေးချယ်မှုများ CSS လုပ်ဆောင်ချက်များ CSS အကိုးအကား Aural CSS ဝဘ်ဘေးကင်းသောဖောင့်များ CSS Animatable CSS ယူနစ်များ CSS PX-EM Converter CSS အရောင်များ CSS အရောင်တန်ဖိုးများ CSS မူရင်းတန်ဖိုးများ CSS Browser ပံ့ပိုးမှု

CSS Opacity/Transparency


ပိုင်ဆိုင်မှု သည် opacityဒြပ်စင်တစ်ခု၏ ပွင့်လင်းမြင်သာမှု/ပွင့်လင်းမှုကို သတ်မှတ်သည်။


ဖောက်ထွင်းမြင်ရသောပုံ

ပိုင်ဆိုင်မှု သည် opacity0.0 မှ 1.0 မှ တန်ဖိုးတစ်ခုယူနိုင်သည်။ တန်ဖိုးနိမ့်လေ၊ ပိုမိုပွင့်လင်းလေဖြစ်သည်-

သစ်တော

opacity 0.2

သစ်တော

opacity 0.5

သစ်တော

အလင်းပိတ်ခြင်း 1
(မူလ)

ဥပမာ

img {
  opacity: 0.5;
}

Transparent Hover Effect

mouse-over တွင် opacity ကိုပြောင်းလဲရန် ပိုင်ဆိုင်မှုကို ရွေးချယ် သည့် opacityကိရိယာနှင့် မကြာခဏတွဲသုံးသည် -:hover

မြောက်ပိုင်းအလင်း
တောင်တွေ
အီတလီ

ဥပမာ

img {
  opacity: 0.5;
}

img:hover {
  opacity: 1.0;
}

နမူနာရှင်းပြထားပါတယ်။

ပထမ CSS ဘလောက်သည် ဥပမာ 1 ပါကုဒ်နှင့် ဆင်တူသည်။ ထို့အပြင်၊ အသုံးပြုသူတစ်ဦးသည် ပုံများထဲမှ တစ်ခုအပေါ်တွင် လျှပ်ပေါ်နေသည့်အခါတွင် ဖြစ်ပျက်ရမည့်အရာများကို ကျွန်ုပ်တို့ ထည့်သွင်းထားသည်။ ဤအခြေအနေတွင် အသုံးပြုသူသည် ၎င်းအပေါ်တွင် ဝဲနေသောအခါတွင် ကျွန်ုပ်တို့သည် ပုံအား ပွင့်လင်းမြင်သာမှု မရှိစေလိုပါ။ ဒီအတွက် CSS က opacity:1;.

မောက်စ်ညွှန်တံသည် ပုံမှရွေ့လျားသောအခါ၊ ရုပ်ပုံသည် တစ်ဖန် ပွင့်လင်းလာမည်ဖြစ်သည်။

ပြောင်းပြန်လှန်ထားသော ပြေးလွှားအကျိုးသက်ရောက်မှု ဥပမာ-

မြောက်ပိုင်းအလင်း
တောင်တွေ
အီတလီ

ဥပမာ

img:hover {
  opacity: 0.5;
}


ဖောက်ထွင်းသေတ္တာ

When using the opacity property to add transparency to the background of an element, all of its child elements inherit the same transparency. This can make the text inside a fully transparent element hard to read:

opacity 1

opacity 0.6

opacity 0.3

opacity 0.1

Example

div {
  opacity: 0.3;
}

Transparency using RGBA

If you do not want to apply opacity to child elements, like in our example above, use RGBA color values. The following example sets the opacity for the background color and not the text:

100% opacity

60% opacity

30% opacity

10% opacity

You learned from our CSS Colors Chapter, that you can use RGB as a color value. In addition to RGB, you can use an RGB color value with an alpha channel (RGBA) - which specifies the opacity for a color.

An RGBA color value is specified with: rgba(red, green, blue, alpha). The alpha parameter is a number between 0.0 (fully transparent) and 1.0 (fully opaque).

Tip: You will learn more about RGBA Colors in our CSS Colors Chapter.

Example

div {
  background: rgba(76, 175, 80, 0.3) /* Green background with 30% opacity */
}

Text in Transparent Box

This is some text that is placed in the transparent box.

Example

<html>
<head>
<style>
div.background {
  background: url(klematis.jpg) repeat;
  border: 2px solid black;
}

div.transbox {
  margin: 30px;
  background-color: #ffffff;
  border: 1px solid black;
  opacity: 0.6;
}

div.transbox p {
  margin: 5%;
  font-weight: bold;
  color: #000000;
}
</style>
</head>
<body>

<div class="background">
  <div class="transbox">
    <p>This is some text that is placed in the transparent box.</p>
  </div>
</div>

</body>
</html>

Example explained

First, we create a <div> element (class="background") with a background image, and a border.

Then we create another <div> (class="transbox") inside the first <div>.

The <div class="transbox"> have a background color, and a border - the div is transparent.

Inside the transparent <div>, we add some text inside a <p> element.


Test Yourself With Exercises

Exercise:

Use CSS to set the transparency of the image to 50%.

<style>
img {
  : ;
}
</style>

<body>
  <img src="klematis.jpg" width="150" height="113">
</body>