Home > Article > Web Front-end > How to modify css style
How to modify the css style: first introduce jQuery; then define the style of the element; then specify the event that triggers the color change; finally use css() to overwrite the style of the original element.
The operating environment of this article: windows7 system, css3&&jquery3.2.1 version, Dell G3 computer.
As shown in the figure, import jQuery, and then define the style of the element according to your own elements. Here I will define the style of the div casually.
Then we look at the effects brought by the style, and then start setting up interactive effects such as changing colors when clicking the button.
First of all, it is natural to specify the event that triggers the color change, which can be through triggering, etc. Here I will click to trigger the color change.
As shown in the picture, you can use css() to overwrite the style of the original element.
#If you are modifying a single style of an element, separate them with commas. Colons are not allowed.
In this way, you can get the interactive effect, but this is only a change in the effect of one style. How to do multiple effects?
You can wrap multiple styles in curly brackets, separate the styles with commas, and then use colons for the style values, so that they are effective.
#Finally, the style interaction is complete. Multiple styles will be modified. You can study more by yourself.
[Recommended learning: css video tutorial]
The above is the detailed content of How to modify css style. For more information, please follow other related articles on the PHP Chinese website!