How to modify element.style style

question:

When we wrote the style of the previous web page, we found that sometimes, no matter how we modify the value in the style, the style on the page will not be modified. When you view it with a tool, you will find that there is a value of element.style in it. This value can't be found where it appears, and it can't be modified.

reason:

In fact, element.style is an inline style. In many cases, it is hard-coded in some JavaScript codes. This method is quite bad. But sometimes, when we use third-party js files, we will encounter them.

Solution:

So how do we modify it, use !important syntax priority in the source code to achieve the effect we want.

Example:

By default, the transparency of the above image is green. We can’t find how to modify the element.style. At this time, we can modify it in the following CSS style sheet:

insert image description here

As shown above, add an opacity: 100 ! important ; to the css style sheet, you can see that the top opacity: 0 is disabled, that is, opacity: 100 is displayed first.

Guess you like

Origin blog.csdn.net/weixin_42365757/article/details/123089225