gpt4 book ai didi

html - css html 页脚问题是否可以解决?

转载 作者:行者123 更新时间:2023-11-28 00:20:53 25 4
gpt4 key购买 nike

我在将页脚文本垂直(高度)居中时遇到了一些主要问题,我确实希望页脚更靠近段落文本。这可能吗? enter image description here

<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="stylefooter.css">
</head>
<body>

<div id="container">
<div id="main">
<p>ffsdergserkghretkguhsritg</p></br>
</div>
</div>

<footer id="footer">
<p>Ohhhh yeah!</p>
</footer>

</body>
</html>
  • {
    margin :0;
    填充:0;

    html,正文{
    高度:100%;

    容器{

    min-height: 100%;

    主要{

    overflow: auto;             
    padding-bottom: 40px;

    页脚{

    background-color: black;
    position: relative;
    height: 40px;
    clear: both;
    text-align: center;
    color: white;

最佳答案

您可以在 css 中使用属性“line-height”并将页脚的高度作为值

footer 
{
height : 40px;
}

footer > p
{
line-height: 40px;
}

更多信息: https://developer.mozilla.org/en-US/docs/Web/CSS/line-height

关于html - css html 页脚问题是否可以解决?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54875526/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com