If the frosted glass effect is done well, it can make the page look very vivid and three-dimensional. Directly on the picture body { min-height: 100vh; box-sizing: border-box; margin: 0; padding-top: calc(50vh - 6em); font: 150%/1.6 serif; background: url("iphone.jpg") fixed 0 center; background-size: cover; } main { margin: 0 auto; padding: 1em; max-width: 30em; border-radius: .3em; box-shadow: 0 0 0 1px hsla(0,0%,100%,.3) inset, 0 .5em 1em rgba(0, 0, 0, 0.6); text-shadow: 0 1px 1px hsla(0,0%,100%,.3); background: hsla(0,0%,100%,.3); } <main>……</main> Remove those style codes, the core code to achieve the frosted glass effect is as follows: body { … background: url("iphone.jpg") fixed 0 center; background-size: cover; } main { … background: hsla(0,0%,100%,.3); } Of course, this effect is still a little far from our expectations, because the simple 30% transparency will make the text difficult to read. For a page, the background image only serves to beautify it, and the text is the core. You can increase the transparency percentage, but then the page will look rigid. In order to make the text easier to read and keep the page lively, you can blur the background of the mian tag above. You might try the blur filter, but unfortunately it doesn’t work properly: main { … -webkit-filter: blur(3px); filter: blur(3px); } Using the blur filter will blur the text, making it even harder to see, so I have to give up. The correct way is to add a pseudo-element ::before to the mian tag and use the blur filter on the pseudo-element: (a red background color is added for demonstration purposes) main { position: relative; … } main::before { content: ''; position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: -1; -webkit-filter: blur(20px); filter: blur(20px); background: rgba(255,0,0,.5); } It can be seen that the blur effect is achieved, but it causes two problems. First of all, due to the blur, an outer shadow appears. This is easy to solve. Just add main { … overflow: hidden; } main::before { … margin: -30px; } Finally, replace the red background color of the pseudo-element with the background image of the body. The effect is as follows. You can also click here and right click to view the complete source code. The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. |
<<: Use docker to deploy tomcat and connect to skywalking
>>: React dva implementation code
The excellence of Linux lies in its multi-user, m...
I recently watched Apple's press conference a...
MySQL 5.7 MySQL command line client using command...
p>Manually start in "Services" and i...
Table of contents Preface 1. Download a single fi...
What is a file system We know that storage engine...
Table of contents Preface 1. JDBC timeout setting...
For a website, it is the most basic function. So l...
Transaction isolation level settings set global t...
Isolation of process address spaces is a notable ...
Single page application characteristics "Ass...
This article shares the specific code for JavaScr...
ElasticSearch cluster supports動態請求的方式and靜態配置文件to ...
This article example shares the specific code of ...
Many times, we ignore the setting of the web page ...