练习10_定位气泡练习.html 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. .bc{
  9. position: fixed;
  10. top:0;
  11. left: 0;
  12. right: 0;
  13. bottom: 0;
  14. background-color: #f0f4c3;
  15. }
  16. /*fixed absolute 定位之后的元素 之前的空间会被释放掉 默认宽度为内容宽度 */
  17. .footer{
  18. position: fixed;
  19. bottom: 0;
  20. left: 0;
  21. z-index: 1;
  22. background-color: #fffde7;
  23. width: 100%;
  24. height: 50px;
  25. text-align: center;
  26. line-height: 50px;
  27. color: #b28704;
  28. }
  29. .content{
  30. width: 500px;
  31. background-color: #fff;
  32. position: absolute;
  33. z-index: 2;
  34. left: 50%;
  35. top:100px;
  36. margin-left: -250px;
  37. text-align: center;
  38. padding:20px;
  39. border-radius: 20px;
  40. }
  41. .content h1{
  42. color: #689f38;
  43. }
  44. .content .info{
  45. width: 300px;
  46. margin: 10px auto;
  47. }
  48. .content .desc{
  49. color: #999;
  50. font-size: 12px;
  51. }
  52. .content .bubble-content{
  53. background-color: #b2dfdb;
  54. width: 500px;
  55. height: 400px;
  56. border-radius: 20px;
  57. position: relative;
  58. }
  59. .content .bubble-content .bubble-one{
  60. width: 50px;
  61. height: 50px;
  62. background-color: red;
  63. border:3px solid #fff;
  64. position: absolute;
  65. left: 50%;
  66. top: 50%;
  67. margin-top: -25px;
  68. margin-left: -25px;
  69. border-radius: 50%;
  70. color: white;
  71. font-weight: bold;
  72. line-height: 50px;
  73. }
  74. .content .bubble-content .bubble-two{
  75. width: 80px;
  76. height: 80px;
  77. border:3px solid #fff;
  78. background-color: #ffd54f;
  79. border-radius: 50%;
  80. color: #fff;
  81. font-weight: bold;
  82. line-height: 80px;
  83. position: absolute;
  84. top: 50px;
  85. left: 50px;
  86. }
  87. .content .bubble-content .bubble-three{
  88. width: 100px;
  89. height: 100px;
  90. border:3px solid #fff;
  91. background-color: #81d4fa;
  92. border-radius: 50%;
  93. color: #fff;
  94. font-weight: bold;
  95. line-height: 100px;
  96. position: absolute;
  97. top: 80px;
  98. left: 80px;
  99. }
  100. .content .bubble-content div::after{
  101. content: "";
  102. display: block;
  103. width: 25%;
  104. height: 20%;
  105. background-color: rgba(255,255,255,0.5);
  106. position: absolute;
  107. top:20%;
  108. left: 20%;
  109. border-radius: 50%;
  110. /* opacity: 0.5; */
  111. }
  112. .content .bubble-content div:hover{
  113. padding: 20px;
  114. margin-top: -20px;
  115. margin-left: -20px;
  116. z-index: 1;
  117. }
  118. .content .bubble-content .bubble-one:hover{
  119. margin-left: -45px;
  120. margin-top: -45px;
  121. }
  122. </style>
  123. </head>
  124. <body>
  125. <div class="bc"></div>
  126. <div class="content">
  127. <h1>趣味气泡 Position 练习</h1>
  128. <p class="info">任务: 观察并理解气泡的定位方式,鼠标悬停气泡试试看!</p>
  129. <p class="desc">(气泡用 absolute,气泡区用 relative,底部说明条用 fixed)</p>
  130. <div class="bubble-content">
  131. <div class="bubble-one">A</div>
  132. <div class="bubble-two">B</div>
  133. <div class="bubble-three">C</div>
  134. </div>
  135. </div>
  136. <div class="footer">
  137. <span>本页面用于练习 position: relative / absolute / fixed 及 hover/伪元素效果</span>
  138. </div>
  139. </body>
  140. </html>