How to invalidate css styles

coldplay.xixi
Release: 2021-04-29 15:19:49
Original
3084 people have browsed it

Methods to invalidate the css style: 1. By changing the element name to invalidate the css in this area; 2. By setting a high-priority css style to overwrite this css style and make it invalid.

How to invalidate css styles

The operating environment of this tutorial: windows7 system, css3 version, DELL G3 computer.

Methods to invalidate the css style:

1. By changing the element name, we can achieve the purpose of invalidating the css in this area.

As we have already If the above separate style is set for #notice, you can cancel the style by changing the name of the element #notice

<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
    $("#notice").attr("id", "notice00");
});
</script>
Copy after login

2. Overwrite this css style to make it invalid by setting a high-priority css style

Use !important to increase style priority.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">  
<head>  
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
<title>Untitled Document</title>  
<style type="text/css">  
.aa{  
        font-family: Verdana, Arial, Helvetica, sans-serif;  
        font-size: 12px;  
        background-color: #FF0000 !important  
}  
.bb{  
        font-family: Verdana, Arial, Helvetica, sans-serif;  
        font-size: 12px;  
        background-color: #FF0000;  
}  
</style>  
</head>  
<body>  
<div class="aa" style="background-color:#cc6600;font-size:16px;">中Class中包括:!important的样式
</div> <div class="bb" style="background-color:#cc6600">不包括的样式</div>  
</body>  
</html>
Copy after login

Rendering:

How to invalidate css styles

Recommended related tutorials: CSS video tutorial

The above is the detailed content of How to invalidate css styles. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
css
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template