_06_a标签.html 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>按钮样式a标签</title>
  6. <style>
  7. /* 重置a标签默认样式:去掉下划线、统一字体 */
  8. a {
  9. text-decoration: none; /* 去掉超链接默认下划线 */
  10. font-family: "Microsoft YaHei", sans-serif; /* 统一字体,更美观 */
  11. font-size: 14px; /* 按钮文字大小 */
  12. }
  13. /* 核心:a标签转按钮样式 */
  14. a {
  15. display: inline-block; /* 关键:让行内的a标签支持宽高、内边距、外边距 */
  16. padding: 8px 16px; /* 按钮内边距:上下8px 左右16px,控制按钮大小 */
  17. margin: 5px; /* 按钮之间的外边距,避免挤在一起 */
  18. background-color: #4299e1; /* 按钮默认背景色(清新蓝,可自行修改) */
  19. color: #ffffff; /* 按钮文字颜色(白色) */
  20. border: none; /* 去掉默认边框 */
  21. border-radius: 4px; /* 按钮圆角,让边角更柔和(值越大越圆) */
  22. cursor: pointer; /* 鼠标悬浮时显示手型,符合按钮的交互习惯 */
  23. transition: background-color 0.2s ease; /* 背景色过渡动画,hover时更丝滑 */
  24. }
  25. /* 鼠标悬浮在按钮上的样式(交互效果) */
  26. a:hover {
  27. background-color: #3182ce; /* 悬浮时背景色加深,有视觉反馈 */
  28. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* 轻微阴影,提升立体感 */
  29. }
  30. /* 可选:鼠标点击按钮时的按下效果 */
  31. a:active {
  32. background-color: #2b6cb0;
  33. box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  34. }
  35. #a1{
  36. width: 1000px;
  37. height: 800px;
  38. background-color: red;
  39. }
  40. #a2{
  41. width: 1000px;
  42. height: 800px;
  43. background-color: yellowgreen;
  44. }
  45. </style>
  46. </head>
  47. <body>
  48. <!--<a href="_01_hello.html">百度</a>-->
  49. <!--<a href="http://www.baidu.com">百度</a>-->
  50. <!--&lt;!&ndash;访问一个图片他可以是网上的一个链接 也可以本地的图片&ndash;&gt;-->
  51. <!--<a href="https://so1.360tres.com/t017d6555a87fb13623.jpg">周杰伦</a>-->
  52. <!--<a href="img/1.png">图片</a>-->
  53. <!--<a href="https://www.renwuji.com/wp-content/uploads/images/2022/12/16/6cf8e9d3ddaa42109abc41284e56adc0~noop_1jlttp0cn4y-480x320.jpg">美女</a>-->
  54. <!--<a href="http://www.baidu.com" target="_blank">百度一下</a>-->
  55. <a href="#n1">第一章</a> <br>
  56. <a href="#n2">第二章</a> <br>
  57. <a id="a1" name="n1" href="#">第一章节内容</a><br>
  58. <a id="a2" name="n2" href="#">第二章节内容</a>
  59. </body>
  60. </html>