—— Alone � ?? 2023-03-11 13:48 采纳率: 40%
浏览 106
已结题

按以下要求完成一个简易移动端页面的布局要求:

6)使用HTML5的语义化标签
7)使用弹性盒子完成布局
8)要求适配所有移动端设备
9)精品推荐只显示4条数据即可
10)顶部的搜索框不随着滚动条的滚动而滚动
11)最终效果与效果图一致 不使用js
12)代码书写规范
实现的效果如下:

img

  • 写回答

3条回答 默认 最新

  •  赵先生. 2023-03-11 17:45
    关注

    以下是该移动端页面的示例代码:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>移动端页面</title>
        <style>
            /* 弹性盒子布局 */
            body {
                display: flex;
                flex-direction: column;
                height: 100vh;
            }
            header {
                flex: 0 0 auto;
                position: fixed;
                top: 0;
                background-color: #fff;
                width: 100%;
                z-index: 1;
            }
            main {
                flex: 1 1 auto;
                padding-top: 60px;
            }
            /* 精品推荐只显示4条数据 */
            .recommendations {
                display: flex;
                flex-wrap: wrap;
                justify-content: space-between;
            }
            .recommendations > li {
                width: 48%;
                margin-bottom: 20px;
            }
            /* 顶部的搜索框不随着滚动条的滚动而滚动 */
            .search-container {
                position: relative;
            }
            .search-container input[type="search"] {
                width: 100%;
                padding: 10px;
                font-size: 16px;
            }
            .search-container button[type="submit"] {
                position: absolute;
                top: 0;
                right: 0;
                height: 100%;
                padding: 10px;
                font-size: 16px;
            }
        </style>
    </head>
    <body>
        <header>
            <div class="search-container">
                <input type="search" placeholder="Search...">
                <button type="submit">Go</button>
            </div>
        </header>
        <main>
            <ul class="recommendations">
                <li><img src="<https://via.placeholder.com/150>"></li>
                <li><img src="<https://via.placeholder.com/150>"></li>
                <li><img src="<https://via.placeholder.com/150>"></li>
                <li><img src="<https://via.placeholder.com/150>"></li>
            </ul>
        </main>
    </body>
    </html>
    
    评论

报告相同问题?

问题事件

  • 系统已结题 3月19日
  • 赞助了问题酬金15元 3月11日
  • 创建了问题 3月11日