Kung paano gumawa: maldilim na background image
Matututunan kung paano gumawa ng maldilim na background image gamit ang CSS.
Maldilim na background image
Babala:Ang eksemplo na ito ay hindi magamit sa Edge 12, IE 11 o mas lumang bersyon.
Kung paano gumawa ng maldilim na background image
第一步 - 添加 HTML:
<div class="bg-image"></div> <div class="bg-text"> <h1>Ako ay Bill Gates</h1> <p>At ang Ako ay Photographer</p> </div>
第二步 - 添加 CSS:
body, html { height: 100%; {} * { box-sizing: border-box; {} .bg-image { /* 所用的图像 */ background-image: url("photographer.jpg"); /* 添加模糊效果 */ filter: blur(8px); -webkit-filter: blur(8px); /* 全高 */ height: 100%; /* 将图像居中并适当地缩放 */ background-position: center; background-repeat: no-repeat; background-size: cover; {} /* 将文本放置在页面/图像的中间 */ .bg-text { background-color: rgb(0,0,0); /* 回退颜色 */ background-color: rgba(0,0,0, 0.4); /* 黑色半透明/可透视 */ color: white; font-weight: bold; border: 3px solid #f1f1f1; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 2; width: 80%; padding: 20px; text-align: center; {}