Home >Web Front-end >Front-end Q&A >How to modify css style

How to modify css style

藏色散人
藏色散人Original
2021-04-26 09:32:184795browse

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.

How to modify css style

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.

How to modify css style

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.

How to modify css style

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.

How to modify css style

As shown in the picture, you can use css() to overwrite the style of the original element.

How to modify css style

#If you are modifying a single style of an element, separate them with commas. Colons are not allowed.

How to modify css style

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?

How to modify css style

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.

How to modify css style

#Finally, the style interaction is complete. Multiple styles will be modified. You can study more by yourself.

How to modify css style

[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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn