1.CLASS和ID的优先级比较.

<!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 content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>无标题 1</title>
<style type="text/css">
    .a h1
{
    color
:fuchsia;
}
    .b h1
{
    color
:lime;
}
    #a h1
{
    color
:fuchsia;
}
    #b h1
{
    color
:lime;
}

</style>
</head>

<body>
<div class="a">
    
<h1>CLASS在前</h1>
    
<div id="b">
        
<h1>ID在后</h1>
    
</div>
</div>
<div class="a">
    
<h1>CLASS在前</h1>
    
<div class="b">
        
<h1>CLASS在后</h1>
    
</div>
</div>
<div id="a">
    
<h1>ID在前</h1>
    
<div class="b">
        
<h1>CLASS在后</h1>
    
</div>
</div>
<div id="a">
    
<h1>ID在前</h1>
    
<div id="b">
        
<h1>ID在后</h1>
    
</div>
</div>

</body>

</html>

 结论:上面的代码说明了在CSS样式中ID的优先级别比CLASS要高.(IE 6 7 8 FF  C结果一致)

相关文章:

  • 2022-02-23
  • 2021-04-24
  • 2021-05-29
  • 2021-10-19
  • 2021-07-15
  • 2021-09-23
猜你喜欢
  • 2021-12-29
  • 2021-10-05
  • 2021-06-15
  • 2021-12-17
  • 2022-12-23
  • 2021-06-30
  • 2021-07-28
相关资源
相似解决方案