需求:一個p設(shè)置了background: url,現(xiàn)在需要使圖片背景模糊,p內(nèi)的文字清晰顯示。
原始代碼:
<!DOCTYPE html><html lang="en"><head> <meta charset="utf-8"> <style type="text/css"> .content { color: #ffffff; font-size: 40px; } .bg { background: url('1.jpg'); background-repeat: no-repeat; background-position: center; background-size: cover; height:600px; text-align: center; line-height: 600px; } </style></head><body><p class="bg"> <p class="content">我是內(nèi)容</p></p></body></html>
原始效果:
解決方法:內(nèi)容和圖片分別置于一個p,通過css設(shè)置背景p模糊度,設(shè)置內(nèi)容p絕對位置。
html代碼:
<!DOCTYPE html><html lang="en"><head> <meta charset="utf-8"> <style type="text/css"> .content { color: #ffffff; font-size: 40px; } .bg { background: url('1.jpg'); height:600px; text-align: center; line-height: 600px; } .bg-blur { float: left; width: 100%; background-repeat: no-repeat; background-position: center; background-size: cover; -webkit-filter: blur(15px); -moz-filter: blur(15px); -o-filter: blur(15px); -ms-filter: blur(15px); filter: blur(15px); } .content-front { position:absolute; left: 10px; right: 10px; height:600px; line-height: 600px; text-align: center; } </style></head><body> <p> <p class="bg bg-blur"></p> <p class="content content-front">我是內(nèi)容</p> </p></p></body></html>
效果:
需求:一個p設(shè)置了background: url,現(xiàn)在需要使圖片背景模糊,p內(nèi)的文字清晰顯示。
原始代碼:
<!DOCTYPE html><html lang="en"><head> <meta charset="utf-8"> <style type="text/css"> .content { color: #ffffff; font-size: 40px; } .bg { background: url('1.jpg'); background-repeat: no-repeat; background-position: center; background-size: cover; height:600px; text-align: center; line-height: 600px; } </style></head><body><p class="bg"> <p class="content">我是內(nèi)容</p></p></body></html>
原始效果:
解決方法:內(nèi)容和圖片分別置于一個p,通過css設(shè)置背景p模糊度,設(shè)置內(nèi)容p絕對位置。
html代碼:
<!DOCTYPE html><html lang="en"><head> <meta charset="utf-8"> <style type="text/css"> .content { color: #ffffff; font-size: 40px; } .bg { background: url('1.jpg'); height:600px; text-align: center; line-height: 600px; } .bg-blur { float: left; width: 100%; background-repeat: no-repeat; background-position: center; background-size: cover; -webkit-filter: blur(15px); -moz-filter: blur(15px); -o-filter: blur(15px); -ms-filter: blur(15px); filter: blur(15px); } .content-front { position:absolute; left: 10px; right: 10px; height:600px; line-height: 600px; text-align: center; } </style></head><body> <p> <p class="bg bg-blur"></p> <p class="content content-front">我是內(nèi)容</p> </p></p></body></html>
效果:
感謝大家的閱讀,希望大家受益良多。
本文轉(zhuǎn)自:https://blog.csdn.net/oHeHeHou/article/details/51975539
推薦教程:《css教程》
文章標(biāo)題:css設(shè)置背景圖片模糊,內(nèi)容不模糊
網(wǎng)站鏈接:http://m.rwnh.cn/article10/cgdpdo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供全網(wǎng)營銷推廣、企業(yè)建站、響應(yīng)式網(wǎng)站、品牌網(wǎng)站制作、網(wǎng)站制作、軟件開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)