Generally, during Qingming Festival, the National Day of Mourning, the day of a major earthquake, and the death or anniversary of some influential great people, as webmasters, we will turn all the pages of our website into gray (black and white) to express our condolences to the deceased. So today let’s talk about how to implement this function through a few simple lines of code. This morning, a netizen mentioned that he hopes to change the overall color tone of the website to gray and black. I remember that this was used in the past to commemorate certain dates, and it was also used on the 123WORDPRESS.COM website. I remember that at that time it could be achieved directly by modifying CSS. Since there are users who need it, I will take some time to sort it out and see if there are other better methods. We can choose the appropriate CSS code style according to actual needs and add it to the code of our own web page template to achieve gray, black and white styles of the web page. First, web page black and white code style A: Modify the CSS file We can add the following CSS code to the CSS file of the web page to make the web page black and white, that is, the website gray CSS Code Web page black and white code style A html { filter: progid:DXImageTransform.Microsoft.BasicImage(grayscale=1); -webkit-filter: grayscale(100%); } This code webpage black and white code style B is also recommended <style> html { -webkit-filter: grayscale(100%); -moz-filter: grayscale(100%); -ms-filter: grayscale(100%); -o-filter: grayscale(100%); filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1); _filter:none; } </style> Here we can add the code to the HEAD template to achieve the whole site. Second method: Add the following code to the <head> tag of the web page If you don't want to modify the CSS file, you can gray out the website pages by adding inline CSS code inside the <head> tag in the header of the web page. Code <style type="text/css"> html { filter: progid:DXImageTransform.Microsoft.BasicImage(grayscale=1); -webkit-filter: grayscale(100%);} </style> The third method: modify the <html> tag to add inline styles If you don't like the above two methods, you can modify the <html> tag to add inline styles to achieve the effect of graying out the web page. Code
Fourth: CSS code used by the author himself Code: body *{ -webkit-filter: grayscale(100%); /* webkit */ -moz-filter: grayscale(100%); /*firefox*/ -ms-filter: grayscale(100%); /*ie9*/ -o-filter: grayscale(100%); /*opera*/ filter: grayscale(100%); filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1); filter:gray; /*ie9- */ } Here, we choose to add to the code according to actual needs. PS: The above methods all control the display of the page through CSS filters. The only difference is the way the CSS code is called. You guys, dig up whichever one you like! |
<<: Vue implements horizontal scrolling of marquee style text
>>: MariaDB-server installation of MySQL series
In new projects, axios can prevent duplicate subm...
You can have the best visual design skills in the...
1. Use ansible's playbook to automatically in...
Table of contents Table/index.js Table/model/inde...
Table of contents question: 1. Enable remote logi...
This article records the installation and configu...
Introduction MySQL achieves high availability of ...
The value of the background property in CSS backg...
HTML provides five space entities with different ...
1. Function: xargs can convert the data separated...
Introduction to HTML HyperText Markup Language: H...
Table of contents MySQL result sorting - Aggregat...
I encountered several browser compatibility issue...
How to solve the Mysql transaction operation fail...
First, let’s take an example: There is a type fie...