【问题标题】:Is the css html footer question possible to resolve?css html页脚问题可以解决吗?
【发布时间】:2019-02-26 06:33:19
【问题描述】:

我在将页脚文本垂直(高度)居中时遇到了一些主要问题,我确实希望页脚更接近段落文本。这可能吗?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>
  • {
    边距: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;
    

    }

【问题讨论】:

  • v-align:center 工作吗?
  • create a Minimal, Complete, and Verifiable example,以便我们更好地为您提供帮助。
  • 贴一些代码...
  • 对不起,我是新手,今天的表格不开心。
  • 解决了两部分问题的第二个问题。我设法(自己)将页脚移到更靠近顶部的位置。现在,是否可以将文本垂直居中?我试过 v-align 但它不起作用。

标签: html css footer


【解决方案1】:

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

footer 
{
    height : 40px;
}

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-11-08
    • 1970-01-01
    • 1970-01-01
    • 2012-11-06
    • 1970-01-01
    • 2011-06-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多