对于某些人来说,这可能是一个非常重要的问题,但由于某种原因,我找不到将文本放置在页面最底部的方法。如果我将位置设置为“固定”,则可以将文本放在底部,但我只是尝试将文本放在页面底部,以便用户在滚动到最底层。
这是我针对这个特定问题的当前代码。由于这是我页面的最底部,我只复制了有问题的相关源代码。
HTML
<div id = "next">
<div id = "opportunities">
<h5>I am looking for opportunities in software development area from January 2022 onwards.
My inbox is always open. Whether you have a question or just want to say hi, I will get back to you as soon
as possible!
</h5>
<p id = "footer-paragraph">Designed & Built by ABCD</p>
</div>
</div>
CSS
#next {
width: 100%;
margin: 300px auto;
margin-left: -30px;
padding: 20px;
margin: 0;
}
#opportunities h5 {
text-align: center;
margin-top: 15px;
}
#opportunities {
position: relative;
}
#footer-paragraph {
height: 50px;
text-align: center;
bottom: 0px;
left: 0px;
right: 0px;
margin-bottom: 0px;
}
如果footer-paragraph
元素的位置是absolute
并且它的所有父元素都有一个默认的位置值( static
),则footer-paragraph
元素被调整到body
标签。
#next {
width: 100%;
margin: 300px auto;
margin-left: -30px;
padding: 20px;
margin: 0;
}
#opportunities h5 {
text-align: center;
margin-top: 15px;
}
#opportunities {
position: static;
}
#footer-paragraph {
width: 100%;
position: absolute;
height: 50px;
text-align: center;
bottom: 0px;
margin: 0 auto;
}
这是您想要的代码片段。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句