The efficiency will not be lower in this way, because only one image is introduced, and as long as the path in src is the same, it will not cause additional pressure on the browser.
On the contrary, if you cut a picture into 5 pieces, the efficiency will be reduced due to excessive loading. Especially when there are a lot of pictures, the loading pressure will be greater.
At this time, canvas can be a good solution. Use canvas to take screenshots and then assign them to p. However, canvas does not support cross-domain images.
I have an idea, first put a big p and set its background image to a large image. Then put a small p inside, set the transparency to 0, and then set the width and color of the border. I don’t know if it’s possible, I might give it a try when I have time.
I saw a library a few days ago, which is somewhat similar to the original poster’s needs Multiple.js
Is it possible that the picture was not cropped, but a few white lines were added to the picture
The efficiency will not be lower in this way, because only one image is introduced, and as long as the path in src is the same, it will not cause additional pressure on the browser.
On the contrary, if you cut a picture into 5 pieces, the efficiency will be reduced due to excessive loading. Especially when there are a lot of pictures, the loading pressure will be greater.
So your solution is a great one.
At this time, canvas can be a good solution. Use canvas to take screenshots and then assign them to p. However, canvas does not support cross-domain images.
You can do it with canvas, canvas has a cropping method
I have an idea, first put a big p and set its background image to a large image.
Then put a small p inside, set the transparency to 0, and then set the width and color of the border.
I don’t know if it’s possible, I might give it a try when I have time.
I saw a library a few days ago, which is somewhat similar to the original poster’s needs
Multiple.js
background-position
That’s it, but it needs to be calculated well. This is how many animation effects are achievedTry using the picture as the background and the white line using broder,
If you only use p css, for a sprite image, set five boxes, set the size, calculate the distance, and set the position
The best is a sprite image, the second best is to cover it with white stripes
Set the background image and then use background-position to set the position of the image background