Use JavaScript to trigger the transition effect.
Using Pseudo classes such as hover and: focus, we can easily switch elements from one style to another, and switching will have a transitional effect. But sometimes we want to use js to drive the transition (that is, to trigger the transition in code.
Like normal transition, create two style rules first. One is the initial state of the element, and the other is the state of transition. Then, use js to modify the style of the corresponding element on the appropriate server.
The following is an example of switching between daily night views:
(1) The scenes and night views are stacked together. The initial transparency of the night view is 0, which is covered above the day view.
(2) Click the "view night view" button. The transparency of the night view gradually changes from 0 to 1, and the screen gradually changes to the night view.
(3) Click the "view the Sun Scene" button. The transparency of the night scene gradually changes from 1 to 0, and the screen looks like a day scene.
The online sample is as follows:
<! Doctype html>
The above section describes how to use JavaScript to trigger the transition effect. I hope it will help you. If you have any questions, please leave a message and I will reply to you in a timely manner. Thank you very much for your support for the help House website!