အပေါ်ပုံးအဆိုပါ အကြောင်းအရာ ဖန်တီးခြင်း
မောက်ခတ်ချိန်တွင် ပုံးပြင် အပေါ် အကြောင်းအရာ ဖန်တီးခြင်း လေ့လာပါ
အပေါ်ပုံးအဆိုပါ အကြောင်းအရာ
ပုံးပြင်အပေါ် မောက်ခတ်ချိန်တွင် အကြောင်းအရာ လေ့လာပါ

အပေါ်ပုံးအဆိုပါ အကြောင်းအရာ ဖန်တီးခြင်း
ပထမပုဒ် - HTML အသုံးပြုပါ
<div class="container"> <img src="img_avatar.png" alt="Avatar" class="image"> <div class="overlay">My Name is John</div> </div>
ဒုတိယပုဒ် - CSS အသုံးပြုပါ
* {box-sizing: border-box} /* အကွန်တက် အဆိုပါ အကြောင်းအရာ ပါဝင်သော အကွန်တက် */ .container { position: relative; width: 50%; max-width: 300px; } /* ပုံးပြင် အပြန်အလည်သတ်မှတ် */ .image { display: block; width: 100%; height: auto; } /* အပေါ်ပုံးအဆိုပါ အကွန်တက် အဆိုပါ အကြောင်းအရာ */ .overlay { position: absolute; bottom: 0; background: rgb(0, 0, 0); background: rgba(0, 0, 0, 0.5); /* အကြောင်းအားကြီး အနီးကန်း */ color: #f1f1f1; width: 100%; transition: .5s ease; opacity:0; color: white; font-size: 20px; padding: 20px; text-align: center; } /* မောက်ခတ်ချိန်တွင် အကွန်တက်အဆိုပါ အကြောင်းအရာ ပြင်းထန်သွား */ .container:hover .overlay { opacity: 1; }
ပါဝင်သော စာမျက်နှာ
စကားရပ်:CSS 图像
စကားရပ်:如何创建图像叠加悬停效果