自适应响应式网页布局
warning:
这篇文章距离上次修改已过192天,其中的内容可能已经有所变动。

部署于 https://akiyamamio.xyz/testdemo
html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Test</title> <link rel="stylesheet" href="./style.css"> <link rel="preconnect" href="https://fonts.gstatic.com"> <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet"> <script src="./script.js"></script> </head> <div class="header"> <div class="h1"> 首页 </div> <div class="h1"> 关于 </div> <div class="h1"> 更多 </div> </div> <body> <div class="m1"></div> <div class="m2"> <div class="m21"> </div> <div class="m22"> </div> <div class="m21"> </div> <div class="m21"> </div> <div class="m21"> </div> </div> </body> </html>
css
body{ margin: 0px; padding: 0px; background-color: white; opacity: 0.8; background-image: url(./material/illust_83594737_20210212_204945.png); background-repeat: no-repeat; background-position: relative; background-attachment:fixed; background-size: 100%; font-family: 'Inter', sans-serif; } .header{ display:table; margin:0 auto; opacity: 0.8; border-radius: 15px; background-color: black; height: 50px; width: 95%; max-width: 1000px; position: -webkit-sticky; position: sticky; top: 10px; } a:link{ color:rgb(248, 248, 248); text-decoration:none; } .m1{ margin: 0px; position: fixed; right: 0px; bottom: 220px; height: 30%; width: 30%; max-width: 200px; max-height: 200px; z-index: -1; opacity: 0.9; } .m2{ top: 30px; display: table; margin:0 auto; width: 60%; max-width: 1000px; position: relative; z-index: -1; opacity: 0.9; } .m21{ display: inline-block; position: static; border-radius: 15px; width: 100%; max-width: 800px; height: 500px; background: #edc0bf; background: linear-gradient(90deg, #edc0bf 0,#c4caef 58%); font-family: 'Inter', sans-serif; } .m22{ right: 10px; bottom: 10px; display: inline-block; position: fixed; border-radius: 15px; width: 200px; height: 200px; max-height: 30%; max-height: 30%; background: #bbf1dd; background: linear-gradient(90deg, #acfff8 0,#c2fad9 58%); font-family: 'Inter', sans-serif; } #d{ object-fit: contain; height: 100%; width: 100%; } .h1{ border-radius: 10px; display:inline-block; height: 46px; width: 80px; color: azure; position: static; text-align: center; line-height: 48px; margin: 2px; }