- Hero Image ကိုဘယ်လိုလုပ်မလဲ။
CSS ဖြင့် Hero Image ဖန်တီးနည်းကို လေ့လာပါ။
Hero Image သည် ဝဘ်စာမျက်နှာတစ်ခု၏ထိပ်တွင် မကြာခဏတင်လေ့ရှိသော စာသားပါသော ကြီးမားသောရုပ်ပုံတစ်ပုံဖြစ်သည်-
သူရဲကောင်းရုပ်ပုံဖန်တီးနည်း
အဆင့် 1) HTML ကိုထည့်ပါ
ဥပမာ
<div class="hero-image">
<div class="hero-text">
<h1>I am John Doe</h1>
<p>And I'm
a Photographer</p>
<button>Hire me</button>
</div>
</div>
အဆင့် 2) CSS ကိုထည့်ပါ
ဥပမာ
body, html {
height: 100%;
}
/* The hero image
*/
.hero-image {
/* Use "linear-gradient" to add a darken background effect
to the image (photographer.jpg). This will make the text
easier to read */
background-image: linear-gradient(rgba(0, 0, 0, 0.5),
rgba(0, 0, 0, 0.5)), url("photographer.jpg");
/* Set a specific height
*/
height:
50%;
/* Position and center the image to scale
nicely on all screens */
background-position: center;
background-repeat: no-repeat;
background-size: cover;
position: relative;
}
/* Place text in the middle of the image */
.hero-text {
text-align: center;
position: absolute;
top: 50%;
left: 50%;
transform:
translate(-50%, -50%);
color: white;
}