如何将 div 元素移动到屏幕底部?

时间:2021-04-21 20:08:00

标签: html

我正在制作一个 html 文件(这只是为了我,并且为了玩得开心编码)并且我需要一个 div 元素(其中包含其他元素)位于我的屏幕底部,但尽管被被另一个元素的边距推动。我使用 margin-bottom:-100px 将播放器部分元素拖到底部。这些是我目前文档中仅有的两个元素(不包括 div 中的元素)。当我运行代码时,播放器部分 div 根本不动。

#output{
    border:solid 2px #234;
    background-color:#234;
    border-radius:10%;
    max-height:100px;
    height:auto;
    padding:5px;
}
#player-section{
    margin-bottom:-100px;
}

这是我目前所拥有的。我使用 -100px 将播放器部分移动到底部,但由于某种原因它不起作用。

1 个答案:

答案 0 :(得分:0)

你可以试试

#output{
    border:solid 2px #234;
    background-color:#234;
    border-radius:10%;
    max-height:100px;
    height:auto;
    padding:5px;
    overflow : auto;
    position: absolute;
    bottom: 0;
}