Two days ago, I wanted to add a shadow effect to an element for a small project, but I remember reading the article "Using Div/CSS to simulate shadow effects" written by an expert, and I still have a little impression. The idea is very simple, mainly using The shadow effect is achieved by positioning offsets of several layers, so I wondered if it could be encapsulated into a js function so that it could be easily called on each html object.
I thought it was very simple at first, but I did encounter many problems during the implementation process. The most serious one was the browser compatibility issue. It took me a whole night and half an overnight to get it done, sweat! However, this little thing gave me a deeper understanding of the differences and solutions between js and some browsers.
Summary it here for future reference!
The code is as follows: