Violet809 2024-04-28 17:56 采纳率: 66.7%
浏览 11

HTML不会修改,如何使底部自然的沉在底部



```html
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <link rel="stylesheet" href="css/index.css">
    <style>
        table, th, td {
            border-collapse: collapse;
            text-align: center;
        }
        table {
            width: 100%;
        }
        th, td {
            border: 1px solid black;
            height: 70px;
        }
        body {
            background-image: url(img/loginbackground.jpg);
            height: 100vh;
        }
        .wrapper {
            border: 1px solid salmon;
            background-color: rgba(142, 143, 132, 0.53);
            margin: 0 auto;
            display: flex;
            justify-content: space-between;
        }
        .wrapper .box {
            display: flex;
            flex-direction: column;
            justify-content: space-between;
        }
        .wrapper {
            margin: auto;
        }
        .item {
            margin-left: 50px;
            margin-right: 50px;
        }
        input[type="submit"] {
            width: 80%;
            height: 40px;
            font-size: 18px;
            background-color: #337ab7;
            color: #FFF;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }
        .shijianbiao {
            background-color: rgba(255, 255, 255, 0.75);
        }
        .denglu {
            height: 400px;
            width: 400px;
            background-color: rgba(255, 255, 255, 0.75);
        }
        .zhuanyejieshao {
        }
        .danzhaoxinwen {
            
        }
        .zhuti {
            text-align: center;
            border-radius: 20px;
            margin: auto;
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
        }
        #dibu {
            clear: both;
            position: fixed;
            bottom: 0;
        }
    </style>
</head>
<body>
    <div id="daohang">
        <div class="dh-right">
            <ul>
                <li>
                    <img src="img/head/1-n.png" alt="">
                    <img src="img/head/zcbm.png" alt="">
                    <br/><span>系统应用</span>
                </li>
                <li>
                    <img src="img/head/1-n.png" alt="">
                    <img src="img/head/zcbm.png" alt="">
                    <br/><span>录取查询</span>
                </li>
                <li>
                    <img src="img/head/1-n.png" alt="">
                    <img src="img/head/zcbm.png" alt="">
                    <br/><span>成绩查询</span>
                </li>
                <li>
                    <img src="img/head/1-n.png" alt="">
                    <img src="img/head/zcbm.png" alt="">
                    <br/><span>打印准考证</span>
                </li>
                <li>
                    <img src="img/head/1-n.png" alt="">
                    <img src="img/head/zcbm.png" alt="">
                    <br/><span>网上缴费</span>
                </li>
                <li>
                    <img src="img/head/1-n.png" alt="">
                    <img src="img/head/zcbm.png" alt="">
                    <br/><span>网上注册</span>
                </li>
            </ul>
        </div>
        <img src="img/head/logo-1.png" alt="logo">
    </div>
    <!-- 在下方DIV中完善页面 -->
    <div style="display: flex; justify-content: center;" class="zhuti">
        <div class="wrapper">
            <div class="box">
                <div class="item shijianbiao" >
                    <h3 style="text-align: center;">最新通知</h3>
                    <p style="text-align: center;">2023年单独招生考试时间安排</p>
                    <table>
                        <tr> 
                            <th colspan="2">时间</th>
                            <th>科目</th>
                            <th>考生类别</th>
                        </tr>
                        <tr>
                            <td rowspan="2">4月5号</td>
                            <td>9:00——11:00</td>
                            <td>文化课考试</td>
                            <td>单独招生(找谁高中毕业生)</td>
                        </tr>
                        <tr>
                            <td>11:00——12:30</td>
                            <td>职业适应性加试</td>
                            <td>单独招生(找谁高中毕业生)</td>
                        </tr>
                        <tr>
                            <td rowspan="2">4月22日</td>
                            <td>9:00——11:00</td>
                            <td>文化课考试</td>
                            <td>单独招生(找谁高中毕业生)</td>
                        </tr>
                        <tr>
                            <td>11:00——12:30</td>
                            <td>职业适应性加试</td>
                            <td>单独招生(找谁高中毕业生)</td>
                        </tr>
                    </table>
                </div>
                <div class="item zhuanyejieshao">
                    <h4>专业介绍</h4>
                    <hr />
                    <ul>
                        <li>软件技术</li>
                        <hr />
                        <li>计算机应用技术</li>
                        <hr />
                        <li>大数据技术</li>
                    </ul>
                </div>
            </div>
            <div class="box">
                <div class="item denglu">
                    <p>身份证号登录</p>
                    <input type="number" placeholder="请输入身份证号"/><br />
                    <input type="password" placeholder="请输入密码"/>
                    <p><a href="">找回密码</a></p>
                    <input type="submit" value="登录" />
                    <input type="submit" value="注册" />
                    <img src="img/rjycma.png" alt="" />
                </div>
                <div class="item danzhaoxinwen">
                    <h4>单招新闻</h4>
                    <hr />
                    <ol>
                        <li>2023年单独招生考试通知</li>
                        <hr />
                        <li>电脑端—报名缴费帮助文档</li>
                        <hr />
                        <li>手机端—报名缴费帮助文档</li>
                    </ol>
                </div>
            </div>
        </div>
    </div>
    <div id="dibu">
        <div style="float: right;">
            <ul style="padding-top: 20px;">
                <li>学校地址:沈阳市沈北新区沈北路53号  邮编:110045</li>
                <li>版权所有:辽ICP备17002625  电话:024-88928718/8719(招生办公室)</li>
                <li>技术支持:沈阳格微软件有限责任公司  技术支持电话:024-88928840-8209</li>
                <li>网站备案/许可证号:辽ICP备17002625号-1</li>
            </ul>
        </div>
        <div style="line-height: 100px;">
            <img src="img/head/logo-1.png" alt="logo">
            <img src="img/2weimaimg.jpg" width="60px" alt="二维码">
            <span>扫描二维码可在手机上登录系统</span>
        </div>
    </div>
</body>
</html>

```

  • 写回答

8条回答 默认 最新

  • 专家-赤兔[在线] 全栈领域优质创作者 2024-04-28 17:56
    关注

    引自免费微信小程序:皆我百晓生

    为了使底部元素自然沉在底部,我们可以对 #dibu 进行一些样式调整。这里提供一个简单的方案:利用 Flex 布局,将整个页面分为两部分,一部分是主要内容区域,另一部分是底部固定区域。首先,我们移除 #daohangposition: fixed 属性,因为这会导致布局混乱。然后,我们将整个页面内容放入一个新的包含器 #container 中,并设置为 Flex 布局。接下来,我们将底部 #dibu 设置为绝对定位,并将其底部对齐。这样,无论屏幕大小如何,底部都会始终位于视口底部。

    下面是修改后的 HTML 和 CSS 代码:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title></title>
        <link rel="stylesheet" href="css/index.css">
        <style>
            /* ... 其他样式保持不变 ... */
    
            /* 新增 #container */
            #container {
                display: flex;
                flex-direction: column;
                min-height: 100vh;
            }
    
            /* 移除 #daohang 的 position:fixed */
            #daohang {
                /* position: fixed; */
                /* top: 0; */
            }
    
            /* 将底部 #dibu 调整为绝对定位 */
            #dibu {
                position: absolute;
                bottom: 0;
                width: 100%;
            }
    
            /* ... 其他样式保持不变 ... */
        </style>
    </head>
    <body>
        <div id="container">
            <div id="daohang">
                <!-- ... 保持不变 ... -->
            </div>
            <!-- 在下方DIV中完善页面 -->
            <div class="zhuti">
                <!-- ... 保持不变 ... -->
            </div>
        </div>
        <div id="dibu">
            <!-- ... 保持不变 ... -->
        </div>
    </body>
    </html>
    

    这个修改应该能让底部元素自然地沉到页面底部。如果你有其他需求或问题,请随时告诉我。

    评论 编辑记录

报告相同问题?

问题事件

  • 创建了问题 4月28日

悬赏问题

  • ¥15 matlab数据降噪处理,提高数据的可信度,确保峰值信号的不损失?
  • ¥15 怎么看我在bios每次修改的日志
  • ¥15 python+mysql图书管理系统
  • ¥15 Questasim Error: (vcom-13)
  • ¥15 船舶旋回实验matlab
  • ¥30 SQL 数组,游标,递归覆盖原值
  • ¥15 为什么我的数据接收的那么慢呀有没有完整的 hal 库并 代码呀有的话能不能发我一份并且我用 printf 函数显示处理之后的数据,用 debug 就不能运行了呢
  • ¥20 gitlab 中文路径,无法下载
  • ¥15 用动态规划算法均分纸牌
  • ¥30 udp socket,bind 0.0.0.0 ,如何自动选取用户访问的服务器IP来回复数据