静态网页入门讲解,制作属于你自己的网页(五)

桃扇骨 2023-07-03 03:21 67阅读 0赞

写在开始

上一次的博客中讲了CSS样式的一些属性以及CSS选择器的种类,链接为:静态网页入门讲解,制作属于你自己的网页(四)

再上一次的博客讲了CSS样式的四种引用方法,链接为[静态网页入门讲解,制作属于你自己的网页(三)

本次博客是CSS样式的一些案例,通过实际的案例来直观感受CSS样式,那么我们就开始吧!

代码实现

1.RGBA透明度效果

  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>RGBA透明度</title>
  5. <style type="text/css">
  6. li.rgba {
  7. float: left;
  8. width: 100px;
  9. height: 80px;
  10. border: #CCC solid 1px;
  11. text-align: center;
  12. font-size: 12px;
  13. }
  14. li.rgba1 {
  15. background: rgba(255, 0, 0, 1);
  16. }
  17. li.rgba2 {
  18. background: rgba(255, 0, 0, 0.8);
  19. }
  20. li.rgba3 {
  21. background: rgba(255, 0, 0, 0.6);
  22. }
  23. li.rgba4 {
  24. background: rgba(255, 0, 0, 0.4);
  25. }
  26. li.rgba5 {
  27. background: rgba(255, 0, 0, 0.2);
  28. }
  29. li.rgba6 {
  30. background: rgba(255, 0, 0, 0);
  31. }
  32. </style>
  33. </head>
  34. <body>
  35. <div class="example-opacity">
  36. <p>CSS3的RGBA效果</p>
  37. <li class="rgba rgba1">Alpha参数为1 </li>
  38. <li class="rgba rgba2">Alpha参数为0.8 </li>
  39. <li class="rgba rgba3">Alpha参数为0.6 </li>
  40. <li class="rgba rgba4">Alpha参数为0.4 </li>
  41. <li class="rgba rgba5">Alpha参数为0.2 </li>
  42. <li class="rgba rgba6">Alpha参数为0 </li>
  43. </div>
  44. </body>
  45. </html>

在这里插入图片描述
2.文字阴影特效

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>文字阴影特效1</title>
  5. <style type="text/css">
  6. p {
  7. text-align: center;
  8. font:bold 60px helvetica, arial, sans-serif;
  9. color: #999;
  10. text-shadow: 0.1em 0.1em #333;
  11. }
  12. </style>
  13. </head>
  14. <body>
  15. <p>CSS3文字阴影特效</p>
  16. </body>
  17. </html>

在这里插入图片描述

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>文字阴影特效2</title>
  5. <style type="text/css">
  6. p {
  7. text-align: center;
  8. font:bold 60px helvetica, arial, sans-serif;
  9. color: #fff;
  10. text-shadow: black 0.1em 0.1em 0.2em;
  11. }
  12. </style>
  13. </head>
  14. <body>
  15. <p>CSS3文字阴影特效</p>
  16. </body>
  17. </html>

在这里插入图片描述

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>文字阴影特效3</title>
  5. <style type="text/css">
  6. body {
  7. background:#000;
  8. }
  9. p {
  10. text-align: center;
  11. font:bold 60px helvetica, arial, sans-serif;
  12. color: red;
  13. text-shadow: 0 0 4px white,
  14. 0 -5px 4px #ff3,
  15. 2px -10px 6px #fd3,
  16. -2px -15px 11px #f80,
  17. 2px -25px 18px #f20;
  18. }
  19. </style>
  20. </head>
  21. <body>
  22. <p>CSS3文字阴影特效</p>
  23. </body>
  24. </html>

在这里插入图片描述
3.立体文字

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>立体文字1</title>
  5. <style type="text/css">
  6. body {
  7. background: #000;
  8. }
  9. p {
  10. text-align: center;
  11. padding: 24px;
  12. margin: 0;
  13. font-family: helvetica, arial, sans-serif;
  14. font-size: 80px;
  15. font-weight: bold;
  16. color: #D1D1D1;
  17. background: #CCC;
  18. text-shadow: -1px -1px white, 1px 1px #333;
  19. }
  20. </style>
  21. </head>
  22. <body>
  23. <p> 立体文字</p>
  24. </body>
  25. </html>

在这里插入图片描述

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>立体文字1</title>
  5. <style type="text/css">
  6. body {
  7. background: #000;
  8. }
  9. p {
  10. text-align: center;
  11. padding: 24px;
  12. margin: 0;
  13. font-family: helvetica, arial, sans-serif;
  14. font-size: 80px;
  15. font-weight: bold;
  16. color: #D1D1D1;
  17. background: #CCC;
  18. text-shadow: 1px 1px white, -1px -1px #333;
  19. }
  20. </style>
  21. </head>
  22. <body>
  23. <p> 立体文字</p>
  24. </body>
  25. </html>

在这里插入图片描述

总结

怎么样?看过这几个具体的案例之后,有没有对CSS的应用有一个直观的印象呢?

当然,CSS应用的方面肯定不止这些,下次的博客中我们来讲一讲关于CSS鼠标悬停动画的一些实际案例,让用户与网页有些简单的交互!

结语

如果说这篇文章有让你学到一定的知识的话,不妨点个赞和关注,让博主能够看到。如果讲解中有什么错误和疏忽,也劳烦在评论中指出或提问,博主会第一时间进行更新和答复,谢谢!

发表评论

表情:
评论列表 (有 0 条评论,67人围观)

还没有评论,来说两句吧...

相关阅读