欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

仅模糊背景图像而不是前面的文本

发布时间:2024/7/5 编程问答 31 豆豆
生活随笔 收集整理的这篇文章主要介绍了 仅模糊背景图像而不是前面的文本 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

正如标题所说。 如何模糊容器的背景图像而不模糊前面的文本?

<div class="card"> <div class="head"> <div class="title"> <span>Card Title</span> </div> </div> <div class="body-container"> <div class="body"> <div class="content"> <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</span> </div> </div> </div> </div>

.container a .body-container { background-image: url("https://i2.wp.com/digital-photography-school.com/wp-content/uploads/2019/02/Landscapes-01-jeremy-flint.jpg"); filter: blur(1px); }

body, html { height: 100%; margin: 0; font-family: Arial, Helvetica, sans-serif; } * { box-sizing: border-box; } .bg-image { /* The image used */ background-image: url("https://i2.wp.com/digital-photography-school.com/wp-content/uploads/2019/02/Landscapes-01-jeremy-flint.jpg"); /* Add the blur effect */ filter: blur(8px); -webkit-filter: blur(8px); /* Full height */ height: 100%; /* Center and scale the image nicely */ background-position: center; background-repeat: no-repeat; background-size: cover; } /* Position text in the middle of the page/image */ .bg-text { background-color: rgb(0, 0, 0); /* Fallback color */ background-color: rgba(0, 0, 0, 0.4); /* Black w/opacity/see-through */ 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; } <div class="bg-image"></div> <div class="bg-text"> <h2>Blurred Background</h2> <h1 style="font-size:50px">I am John Doe</h1> <p>And I'm a Photographer</p> </div>

转载于:https://www.cnblogs.com/gamecenter/p/11096028.html

总结

以上是生活随笔为你收集整理的仅模糊背景图像而不是前面的文本的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。