This article describes in detail the Code related to js sliding door effects, which has some reference value, interested friends can refer to the examples in this article to share with you the specific code of the sliding door effect for your reference. The specific content is as follows:
Sliding Door effect:
Principle:
There are four doors in total. Initially, the first door is opened, and the other three doors are closed, as shown in the first figure.
Assume that the image width is 120px, and the other three door Exposure width is 80px.
In the initial state,
The left distance of the second door is 120px,
The distance to the left of the third door is 200px,
The left distance of the fourth door is 280px.
When the second door opens,
The left distance of the second door is 80 px, which is (120-40) px.
The distance to the left of the third and fourth doors remains unchanged.
When the third door opens,
The left distance of the second door is 80 PX,
The left distance of the third door is 160px. (200-40) px
The fourth door remains unchanged
Therefore, when each door is opened, the image width minus the exposed width is the distance to move to the left. The third door opens. The second door needs to be moved first, and then the third door moves. The distance between each door is the image width minus the exposed width.
Program: