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

问题描述 投票:0回答:1

我有一些主要问题垂直居中页脚文本(高度),我希望页脚更接近段落文本。这可能吗?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,body { 身高:100%; } 容器 { min-height: 100%; } 主{ overflow: auto; padding-bottom: 40px; } 页脚{ background-color: black; position: relative; height: 40px; clear: both; text-align: center; color: white; }
html css footer
1个回答
0
投票

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

footer 
{
    height : 40px;
}

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

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

© www.soinside.com 2019 - 2024. All rights reserved.