博主信息
博文 46
粉丝 2
评论 0
访问量 30195
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
样式优先级
P粉314265155
原创
609人浏览过

我是内联样式

  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>我是内联样式</title>
  8. </head>
  9. <body>
  10. <h1 style="color: red;">我是内联样式</h1>
  11. </body>
  12. </html>

我是文档样式

  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>我是文档样式</title>
  8. <style>
  9. h1{
  10. color: brown;
  11. }
  12. </style>
  13. </head>
  14. <body>
  15. <h1 style="color: red;">我是内联样式红色
  16. </h1>
  17. <h1 style="color:blue ;">我是内联样式蓝色</h1>
  18. <h1>我是文档样式</h1>
  19. <!-- 以上判断内联样式优先级高于 文档样式 高于默认样式 -->
  20. </body>
  21. </html>

我是外联样式

  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>我是外联样式</title>
  8. <link rel="stylesheet" href="../0706/css/zuoye3.css">
  9. <style>
  10. h1{
  11. color: brown;
  12. }
  13. </style>
  14. </head>
  15. <body>
  16. <h1 style="color: red;">我是内联样式红色
  17. </h1>
  18. <h1 style="color:blue ;">我是内联样式蓝色</h1>
  19. <h1>我是文档样式</h1>
  20. <!-- 以上判断内联样式优先级高于 文档样式 高于默认样式 -->
  21. <h2>我是外部样式</h2>
  22. </body>
  23. </html>
  1. /* 我是外联样式 */
  2. h1{
  3. color: blueviolet;
  4. }
  5. h2{
  6. color: aquamarine;
  7. }

我是基本选择器

  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>基本选择器</title>
  8. <link rel="stylesheet" href="../0706/css/zuoye4.css">
  9. </head>
  10. <body>
  11. <h1>我是标签选择器</h1>
  12. <h2 title="shuxing">我是属性选择器</h2>
  13. <h3 id="di">我是id属性选择器</h3>
  14. <h4 class="cl">我是class属性选择器</h4>
  15. <h5 id="qun" >我是群组选择器 1</h5>
  16. <h5 class="zu">我是群组选择器2</h5>
  17. </body>
  18. </html>
  1. /* 基本选择器 */
  2. /* 1、标签选择器 */
  3. h1{
  4. color: blue;
  5. }
  6. /* 2、属性选择器 */
  7. h2[title='shuxing']{
  8. color: green;
  9. }
  10. /* 2.1 id 属性选择器 */
  11. h3#di {
  12. color: brown;
  13. }
  14. /* 2.2 class 属性选择器 */
  15. h4.cl{
  16. color: blue;
  17. }
  18. /* 3、群组选择器 */
  19. h5.qun,
  20. h5#zu,
  21. h5#qun,
  22. h5.zu
  23. {
  24. color: gold;
  25. }
  26. /* 4、通配属性选择器 */
  27. /* * : 包括了h2,h3 ... */
  28. /* body * { */
  29. /* !important: 临时提权到最高权重,用于调试 */
  30. /* background-color: gray !important; */
  31. /* } */
  32. body * {
  33. background-color: aqua !important;
  34. }

我是上下文选择器

  1. /* 我是上下文选择器 */
  2. /* 1、子元素选择器 用 > 连接*/
  3. .ul>.li{
  4. color: aqua;
  5. }
  6. /* 2、我是后代选择器 用 空格 连接 */
  7. .ul .li{
  8. color: blue;
  9. }
  10. /* 3、我是兄弟选择器 用 + 连接 */
  11. .ul .li+li.five{
  12. color: red;
  13. }
  14. /* 我是兄弟选择器 用 星号连接 */
  15. .ul .li+li.five+*{
  16. color: blueviolet;
  17. }
  18. /* 4、我是所有兄弟选择器 用 ~ 连接 */
  19. .ul .li+li.five~*{
  20. color: green;
  21. }
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>上下文选择器</title>
  8. <link rel="stylesheet" href="../0706/css/zuoye5.css">
  9. </head>
  10. <body>
  11. <ul class="ul">
  12. <li class="li">我是子元素选择器1</li>
  13. <li class="li">我是子元素选择器2</li>
  14. <li class="li">我是子元素选择器3</li>
  15. <li class="li">我是后代选择器4</li>
  16. <li class="li five">我是兄弟选择器5</li>
  17. <li class="li five six">我是兄弟选择器6</li>
  18. <li class="li five six sev">我是所有兄弟选择器7</li>
  19. <li class="li five six sev ei">我是所有兄弟选择器7</li>
  20. </ul>
  21. </body>
  22. </html>

我是优先级权重分析

  1. /* 我是优先级权重选择器 */
  2. /* 选择器种类 权值基数 权级 */
  3. /* !important 10000 5级 */
  4. /* 内联样式 1000 4级 */
  5. /* id选择器 100 3级 */
  6. /* class选择器 10 2级 */
  7. /* 元素选择器 1 1级 */
  8. /* 通配符选择器 0 0级 */

批改老师:PHPzPHPz

批改状态:合格

老师批语:
本博文版权归博主所有,转载请注明地址!如有侵权、违法,请联系admin@php.cn举报处理!
全部评论 文明上网理性发言,请遵守新闻评论服务协议
0条评论
作者最新博文
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号

  • 登录PHP中文网,和优秀的人一起学习!
    全站2000+教程免费学