| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- <!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>
- .bc{
- position: fixed;
- top:0;
- left: 0;
- right: 0;
- bottom: 0;
- background-color: #f0f4c3;
- }
- /*fixed absolute 定位之后的元素 之前的空间会被释放掉 默认宽度为内容宽度 */
- .footer{
- position: fixed;
- bottom: 0;
- left: 0;
- z-index: 1;
- background-color: #fffde7;
- width: 100%;
- height: 50px;
- text-align: center;
- line-height: 50px;
- color: #b28704;
- }
- .content{
- width: 500px;
- background-color: #fff;
- position: absolute;
- z-index: 2;
- left: 50%;
- top:100px;
- margin-left: -250px;
- text-align: center;
- padding:20px;
- border-radius: 20px;
- }
- .content h1{
- color: #689f38;
- }
- .content .info{
- width: 300px;
- margin: 10px auto;
- }
- .content .desc{
- color: #999;
- font-size: 12px;
- }
- .content .bubble-content{
- background-color: #b2dfdb;
- width: 500px;
- height: 400px;
- border-radius: 20px;
- position: relative;
- }
- .content .bubble-content .bubble-one{
- width: 50px;
- height: 50px;
- background-color: red;
- border:3px solid #fff;
- position: absolute;
- left: 50%;
- top: 50%;
- margin-top: -25px;
- margin-left: -25px;
- border-radius: 50%;
- color: white;
- font-weight: bold;
- line-height: 50px;
- }
- .content .bubble-content .bubble-two{
- width: 80px;
- height: 80px;
- border:3px solid #fff;
- background-color: #ffd54f;
- border-radius: 50%;
- color: #fff;
- font-weight: bold;
- line-height: 80px;
- position: absolute;
- top: 50px;
- left: 50px;
- }
- .content .bubble-content .bubble-three{
- width: 100px;
- height: 100px;
- border:3px solid #fff;
- background-color: #81d4fa;
- border-radius: 50%;
- color: #fff;
- font-weight: bold;
- line-height: 100px;
- position: absolute;
- top: 80px;
- left: 80px;
- }
- .content .bubble-content div::after{
- content: "";
- display: block;
- width: 25%;
- height: 20%;
- background-color: rgba(255,255,255,0.5);
- position: absolute;
- top:20%;
- left: 20%;
- border-radius: 50%;
- /* opacity: 0.5; */
- }
- .content .bubble-content div:hover{
- padding: 20px;
- margin-top: -20px;
- margin-left: -20px;
- z-index: 1;
- }
- .content .bubble-content .bubble-one:hover{
- margin-left: -45px;
- margin-top: -45px;
- }
- </style>
- </head>
- <body>
- <div class="bc"></div>
- <div class="content">
- <h1>趣味气泡 Position 练习</h1>
- <p class="info">任务: 观察并理解气泡的定位方式,鼠标悬停气泡试试看!</p>
- <p class="desc">(气泡用 absolute,气泡区用 relative,底部说明条用 fixed)</p>
- <div class="bubble-content">
- <div class="bubble-one">A</div>
- <div class="bubble-two">B</div>
- <div class="bubble-three">C</div>
- </div>
- </div>
- <div class="footer">
- <span>本页面用于练习 position: relative / absolute / fixed 及 hover/伪元素效果</span>
- </div>
- </body>
- </html>
|