您好,欢迎访问一九零五行业门户网

如何让css样式失效

让css样式失效的方法:1、通过更改元素名称,来达到让此区域css失效的目的;2、通过设置优先级高的css样式来覆盖此css样式使其失效。
本教程操作环境:windows7系统、css3版,dell g3电脑。
让css样式失效的方法:
一、通过更改元素名称,来达到让此区域css失效的目的
如我们已经为#notice设置了如上的单独样式,可以通过更改元素#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>
二、通过设置优先级高的css样式来覆盖此css样式使其失效
使用!important提升样式优先级。
<!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>
效果图:
相关教程推荐:css视频教程
以上就是如何让css样式失效的详细内容。
其它类似信息

推荐信息