当前位置:   article > 正文

css补充

css补充
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Document</title>
  7. <style>
  8. .c1 {
  9. color: red;
  10. font-size: 16px;
  11. border: 1px solid red;
  12. }
  13. .c1:hover {
  14. color: green;
  15. font-size: 40px;
  16. border: 5px solid green;
  17. }
  18. .c2 {
  19. color: red;
  20. font-size: 16px;
  21. border: 1px solid red;
  22. }
  23. .download {
  24. display: none;
  25. }
  26. .c2:hover .download {
  27. display: block;
  28. }
  29. </style>
  30. </head>
  31. <body>
  32. <div class="c1">hello world</div>
  33. <div class="c2">
  34. <img src="https://desk-fd.zol-img.com.cn/t_s960x600c5/g2/M00/01/0F/ChMlWVXK9e6INH9pAAWhh3ahSqQAAHsHgGHZMgABaGf864.jpg"
  35. height="100px" width="100px" alt="">
  36. <div class="download">
  37. <img src=" https://i1.mifile.cn/f/i/17/appdownload/download.png?1" alt="">
  38. </div>
  39. </div>
  40. </body>
  41. </html>

一些影藏的东西可以用鼠标悬浮显示

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Title</title>
  6. <style>
  7. .c1:after {
  8. content: "yysd";
  9. }
  10. </style>
  11. </head>
  12. <body>
  13. <div class="c1">huakka</div>
  14. <div class="c1">balala</div>
  15. </body>
  16. </html>
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Title</title>
  6. <style>
  7. .clearfix:after {
  8. content: "";
  9. display: block;
  10. clear: both;
  11. }
  12. .item {
  13. float: left;
  14. }
  15. .bg {
  16. background-color: blue;
  17. }
  18. </style>
  19. </head>
  20. <body>
  21. <div class=" bg">
  22. <div class="clearfix">
  23. <div class="item">yyyyy</div>
  24. <div class="item">xxx</div>
  25. <div class="item"><img src="https://i1.mifile.cn/f/i/17/appdownload/download.png?1" alt=""></div>
  26. </div>
  27. </div>
  28. </body>
  29. </html>
  1. .clearfix:after {
  2. content: "";
  3. display: block;
  4. clear: both;
  5. }
  6. 这个css伪类选择器直接在那些浮动标签后面加了块级空格,并clear:both,和那个直接div clear:both一样

 

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Title</title>
  6. <style>
  7. .back {
  8. position: fixed;
  9. width: 60px;
  10. height: 60px;
  11. border: 1px solid black;
  12. right: 10px;
  13. bottom: 50px;
  14. }
  15. </style>
  16. </head>
  17. <body>
  18. <div style="height: 10000px;background-color: #5f5750">
  19. <div class="back"></div>
  20. <img src="https://sjbz-fd.zol-img.com.cn/t_s1080x1920c/g5/M00/00/02/ChMkJ1fJVFOIV8kdAC3oDpyfq8YAAU9wQN1ivcALegm011.jpg"
  21. alt="">
  22. <img src="https://sjbz-fd.zol-img.com.cn/t_s1080x1920c/g5/M00/00/02/ChMkJ1fJVFOIV8kdAC3oDpyfq8YAAU9wQN1ivcALegm011.jpg"
  23. alt="">
  24. <img src="https://sjbz-fd.zol-img.com.cn/t_s1080x1920c/g5/M00/00/02/ChMkJ1fJVFOIV8kdAC3oDpyfq8YAAU9wQN1ivcALegm011.jpg"
  25. alt="">
  26. <img src="https://sjbz-fd.zol-img.com.cn/t_s1080x1920c/g5/M00/00/02/ChMkJ1fJVFOIV8kdAC3oDpyfq8YAAU9wQN1ivcALegm011.jpg"
  27. alt="">
  28. <img src="https://sjbz-fd.zol-img.com.cn/t_s1080x1920c/g5/M00/00/02/ChMkJ1fJVFOIV8kdAC3oDpyfq8YAAU9wQN1ivcALegm011.jpg"
  29. alt="">
  30. <img src="https://sjbz-fd.zol-img.com.cn/t_s1080x1920c/g5/M00/00/02/ChMkJ1fJVFOIV8kdAC3oDpyfq8YAAU9wQN1ivcALegm011.jpg"
  31. alt="">
  32. <img src="https://sjbz-fd.zol-img.com.cn/t_s1080x1920c/g5/M00/00/02/ChMkJ1fJVFOIV8kdAC3oDpyfq8YAAU9wQN1ivcALegm011.jpg"
  33. alt="">
  34. <img src="https://sjbz-fd.zol-img.com.cn/t_s1080x1920c/g5/M00/00/02/ChMkJ1fJVFOIV8kdAC3oDpyfq8YAAU9wQN1ivcALegm011.jpg"
  35. alt="">
  36. <img src="https://sjbz-fd.zol-img.com.cn/t_s1080x1920c/g5/M00/00/02/ChMkJ1fJVFOIV8kdAC3oDpyfq8YAAU9wQN1ivcALegm011.jpg"
  37. alt="">
  38. </div>
  39. </body>
  40. </html>

 

  1. <div class="back"></div>
  2. 这个位置可以随便放

 


 

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Title</title>
  6. <style>
  7. body {
  8. margin: 0;
  9. }
  10. .dialog {
  11. position: fixed;
  12. height: 300px;
  13. width: 500px;
  14. background-color: white;
  15. left: 0;
  16. right: 0;
  17. margin: 0 auto;
  18. top: 200px;
  19. z-index: 1000;
  20. }
  21. .mask {
  22. background-color: black;
  23. position: fixed;
  24. left: 0;
  25. right: 0;
  26. top: 0;
  27. bottom: 0;
  28. opacity: 1;
  29. z-index: 999;
  30. }
  31. </style>
  32. </head>
  33. <body>
  34. <div style="height: 1000px" color="white">asdfasdfasd</div>
  35. <div class="mask"></div>
  36. <div class="dialog"></div>
  37. </body>
  38. </html>

   z-index属性值越大就在显示层上层,opacity透明度为1时会让mask让背景全黑,看不到文字

 

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Title</title>
  6. <style>
  7. .c1 {
  8. height: 300px;
  9. width: 500px;
  10. border: 1px solid red;
  11. margin: 100px;
  12. position: relative;
  13. }
  14. .c1 .c2 {
  15. height: 59px;
  16. width: 59px;
  17. background-color: #00FF7F;
  18. position: absolute;
  19. right: 20px;
  20. bottom: 10px;
  21. }
  22. </style>
  23. </head>
  24. <body>
  25. <div class="c1">
  26. <div class="c2"></div>
  27. </div>
  28. </body>
  29. </html>

 这个ralative就是给这个标签内的标签提供相对定位参照

 

 

 

 

id选择器,标签选择器,类选择器,后代选择,属性选择,伪类选择都可以一直嵌套下去

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/323464
推荐阅读
相关标签
  

闽ICP备14008679号