123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- <style>
- body{
- background-color: #f0f4c3;
- }
- .content{
- width: 600px;
- height: 600px;
- background-color: #fff;
- position: absolute;
- top: 50%;
- left: 50%;
- margin-top: -300px;
- margin-left: -300px;
- border-radius: 20px;
- box-shadow: 0 0 10px rgba(0,0,0,0.5);
- padding-top: 20px;
- }
- .content-info h1{
- text-align: center;
- color: #689f38;
- }
- .content-info .info-center{
- width: 300px;
- margin: 0 auto;
- text-align: center;
- }
- .content-info .info-bottom{
- text-align: center;
- color: #999;
- font-size: 12px;
- }
- .content-bubble{
- width: 500px;
- height: 350px;
- background-color: #b2dfdb;
- margin:0 auto;
- border-radius: 20px;
- position: relative;
- }
- .bubble-item{
- width: 100px;
- height: 100px;
- background-color: #81d4fa;
- border-radius: 50%;
- border:3px solid #fff;
- position: absolute;
- top:50%;
- margin-top: -50px;
- left:30px;
- text-align: center;
- line-height: 100px;
- }
- .bubble-item span{
- color: #fff;
- }
- .bubble-item::after{
- content: "";
- display: block;
- width: 30%;
- height: 20%;
- background-color: #fff;
- position: absolute;
- top:20%;
- left: 20%;
- border-radius: 50%;
- opacity: 0.3;
- }
- .bubble-item:nth-child(2){
- left: 23%;
- top: 40%;
- background-color: #ffd54f;
- width: 80px;
- height: 80px;
- line-height: 80px;
- }
- .bubble-item:nth-child(3){
- left: 53%;
- top: 60%;
- background-color: red;
- width: 60px;
- height: 60px;
- line-height: 60px;
-
- }
- .bubble-item:hover{
- cursor: pointer;
- z-index: 1;
- /* 控制元素缩放 */
- transform: scale(1.2);
- }
- /* .bubble-item:first-child:hover{
- width: 108px;
- height: 108px;
- } */
- .footer{
- background-color: #fffde7;
- color: #b28704;
- /* 脱离文档流后的元素宽度跟内容撑开 */
- position: fixed;
- left: 0;
- bottom: 0;
- width: 100%;
- text-align: center;
- }
- </style>
- </head>
- <body>
- <div class="container">
- <div class="content">
- <div class="content-info">
- <h1>趣味气泡 Position 练习</h1>
- <p class="info-center"><strong>任务:</strong> 观察并理解气泡的定位方式,鼠标悬停气泡试试看!</p>
- <p class="info-bottom">(气泡用 absolute,气泡区用 relative,底部说明条用 fixed)</p>
- </div>
- <div class="content-bubble">
- <div class="bubble-item">
- <span>A</span>
- </div>
- <div class="bubble-item">
- <span>B</span>
- </div>
- <div class="bubble-item">
- <span>C</span>
- </div>
- </div>
- </div>
- <div class="footer">
- <p>本页面用于练习 position: relative / absolute / fixed 及 hover/伪元素效果</p>
- </div>
- </div>
- </body>
- </html>
|