| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- <!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>
- /* css reset */
- * {
- margin: 0;
- padding: 0;
- }
- .fullscreen-container {
- /* height: 100vh;
- width: 100vw; */
- background-color: #f0f4c3;
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- }
- .bubble-container {
- width: 500px;
- height: 600px;
- background-color: #fff;
- z-index: 1000;
- position: fixed;
- top: 50%;
- left: 50%;
- margin-top: -300px;
- margin-left: -250px;
- padding: 20px;
- box-sizing: border-box;
- }
- .bottom-info {
- /* 如果块元素定位后fixed 和 absolute宽度会变成内容的宽*/
- position: fixed;
- bottom: 0;
- left: 0;
- height: 50px;
- width: 100%;
- text-align: center;
- line-height: 50px;
- color: #b28704;
- background-color: #fffde7;
- }
- .bubble-container .text {
- text-align: center;
- }
- .bubble-container .text h1 {
- color: #689f38;
- margin: 20px 0;
- }
- .bubble-container .text .info {
- width: 300px;
- margin: 0 auto;
- }
- .bubble-container .text .desc {
- font-size: 12px;
- color: #999;
- margin-top: 20px;
- }
- .bubble-container .bubble-content {
- width: 100%;
- height: 380px;
- background-color: #b2dfdb;
- margin-top: 20px;
- border-radius: 20px;
- position: relative;
- }
- .bubble-content .bubble-item {
- border-radius: 50%;
- color: #fff;
- font-weight: bold;
- font-size: 24px;
- text-align: center;
- border:3px solid #fff;
- line-height: 100px;
- width: 100px;
- height: 100px;
- background-color: red;
- }
- .bubble-content .bubble-one {
- width: 50px;
- height: 50px;
- line-height: 50px;
- position: absolute;
- top:50%;
- left: 50%;
- margin-top: -25px;
- margin-left: -25px;
- }
- .bubble-content .bubble-two {
- background-color: #ffd54f;
- width: 80px;
- height: 80px;
- line-height: 80px;
- position: absolute;
- top:30px;
- left:30px;
- }
- .bubble-content .bubble-three {
- width: 100px;
- height: 100px;
- line-height: 100px;
- background-color: #81d4fa;
- position: absolute;
- top:60px;
- left:60px;
- }
- .bubble-content .bubble-item::after{
- content: '';
- display: block;
- width: 20%;
- height: 15%;
- background-color: rgba(0, 0, 0, 0.3);
- position: absolute;
- top: 20%;
- left: 20%;
- border-radius: 50%;
- }
- /* .bubble-content .bubble-one:hover{
- width: 60px;
- height: 60px;
- margin-top: -30px;
- margin-left: -30px;
- line-height: 60px;
- } */
- .bubble-content .bubble-item:hover{
- /* transform 变形 scale 缩放 */
- transform: scale(1.5);
- z-index: 1000;
- }
-
- </style>
- </head>
- <body>
- <!-- 全屏容器 -->
- <div class="fullscreen-container"></div>
- <!-- 定位气泡容器 -->
- <div class="bubble-container">
- <div class="text">
- <h1>趣味气泡 Position 练习</h1>
- <p class="info">任务: 观察并理解气泡的定位方式,鼠标悬停气泡试试看!</p>
- <p class="desc">(气泡用 absolute,气泡区用 relative,底部说明条用 fixed)</p>
- </div>
- <div class="bubble-content">
- <div class="bubble-item bubble-one">A</div>
- <div class="bubble-item bubble-two">B</div>
- <div class="bubble-item bubble-three">C</div>
- </div>
- </div>
- <!-- 底部信息 -->
- <div class="bottom-info">本页面用于练习 position: relative / absolute / fixed 及 hover/伪元素效果</div>
- </body>
- </html>
|