Html 从底部绝对定位

Html 从底部绝对定位,html,css,Html,Css,我的网页在屏幕上看起来很好。我把所有的div都放在body标签上,body具有相对中毒性,因此它可以充当网页的容器。我唯一做不到的就是让身体内的div从底部绝对定位。我不知道为什么这样不行。因为当我在另一个屏幕上访问页面时,当我使用top时,div的位置不是一直向下,所以我尝试使用bottom定位 HTML代码: <body> <div id="statement_div"> <p id="statement"> Access to Every Bad

我的网页在屏幕上看起来很好。我把所有的div都放在
body
标签上,body具有相对中毒性,因此它可以充当网页的容器。我唯一做不到的就是让身体内的div从底部绝对定位。我不知道为什么这样不行。因为当我在另一个屏幕上访问页面时,当我使用top时,div的位置不是一直向下,所以我尝试使用bottom定位

HTML代码:

<body>
    <div id="statement_div"> <p id="statement"> Access to Every Bad Movie Ever. </p>  </div>

    <div id="signin_button"> <span style="position: relative; top: 3px"> Sign In </span> </div>
    <div id="create_account_button"> <span style="position: relative; top: 3px"> Create Account </span> </div> 
</div>

为什么不尝试使用
位置:固定的
?例如:

#signin_button {
    width: 12%;
    min-width: 150px;
    height: 40px;
    color: white;
    background-color: #FF3030;
    cursor: pointer;
    text-align: center;
    position: fixed; /* this is the only thing you need to do differently */
    bottom: 10px;
    left: 70%;
    font-size: 20px;
    border-radius: 5px;
    font-family: Futura;
}

主体的最小高度应设置为100vh(100%视口高度)

正文{
背景重复:无重复中心;
背景尺寸:封面;
背景附件:固定;
保证金:0;
身高:100%;
宽度:100%;
最小宽度:1200px;
位置:相对位置;
/*这里是交易*/分钟高度:100vh;
}
#登录按钮{
宽度:12%;
最小宽度:150px;
高度:40px;
颜色:白色;
背景色:#FF3030;
光标:指针;
文本对齐:居中;
位置:绝对位置;
底部:10px;
左:70%;
字体大小:20px;
边界半径:5px;
字体系列:Futura;
}
#创建帐户按钮{
宽度:16%;
最小宽度:150px;
高度:40px;
颜色:白色;
背景色:#3399FF;
光标:指针;
文本对齐:居中;
位置:绝对位置;
底部:10px;
左:83%;
字体大小:20px;
边界半径:5px;
字体系列:Futura;
}

访问每一部糟糕的电影

登录 创建帐户
只需删除
位置:相对body
标记中选择code>样式,因为这是非常不必要的,并且会导致问题,因为此时body的高度是100%的内容高度,而不是屏幕高度

绝对定位是一种非常糟糕的网页布局方法。它极不灵活,而且有更好、更灵活的选择。退房
#signin_button {
    width: 12%;
    min-width: 150px;
    height: 40px;
    color: white;
    background-color: #FF3030;
    cursor: pointer;
    text-align: center;
    position: fixed; /* this is the only thing you need to do differently */
    bottom: 10px;
    left: 70%;
    font-size: 20px;
    border-radius: 5px;
    font-family: Futura;
}