如何在HTML中将页脚与底部中心对齐

如何在HTML中将页脚与底部中心对齐,html,Html,我想将页脚对齐在页面的底部中心,但下面的代码不起作用。你能告诉我应该做些什么改变吗 <style type="text/css"> #footer { bottom : 2; height : 40px; margin-top : 40px; text-align: center; vertical-align: middle; } </style> <div id="footer">

我想将页脚对齐在页面的底部中心,但下面的代码不起作用。你能告诉我应该做些什么改变吗

<style type="text/css">  
  #footer {  
   bottom : 2;  
   height : 40px;  
   margin-top : 40px;  
   text-align: center;  
   vertical-align: middle;  

  }  
</style>  
<div id="footer">Terms and Conditions </div>  

#页脚{
底部:2;
高度:40px;
边缘顶端:40px;
文本对齐:居中;
垂直对齐:中间对齐;
}  
条款和条件
尝试以下代码:

  <style type="text/css">  
  #footer {  
   bottom : 2; 
   padding-bottom: 0; 
   height : 40px;  
   margin-top : 40px; 
   margin: auto;
   width: 50%;
   text-align: center;  
  }  
</style>  
<div id="footer">Terms and Conditions </div>  

#页脚{
底部:2;
填充底部:0;
高度:40px;
边缘顶端:40px;
保证金:自动;
宽度:50%;
文本对齐:居中;
}  
条款和条件

您可以根据自己的意愿更改宽度

以将定义宽度所需的大部分内容居中,然后让自动边距取代其余部分

<style type="text/css">  
  #footer {  
   bottom : 2;  
   height : 40px;   
   text-align: center;  
   vertical-align: middle;


   width:950px;
   margin:40px auto 0;  

  }  
</style>

#页脚{
底部:2;
高度:40px;
文本对齐:居中;
垂直对齐:中间对齐;
宽度:950px;
保证金:40px自动0;
}  
试试这个

#footer {  
     height: 100px;
     margin-top: -50px;
     position: fixed;
     bottom:0;
     width: 100%;
     z-index: 1;
     text-align:center;
  }

首先
底部的
值应在
px
%
中。选中此项,只有当您将其与任何
位置
属性组合时,它才会起作用,请选中此项

如果您想将页脚始终放在页面底部,您可以结合使用
位置:fixed
底部:

并最终设置div
宽度:100%
以使其占据浏览器窗口的整个宽度
像这样,

 #footer {  
   bottom : 2px;  
   height : 40px;  
   margin-top : 40px;  
   text-align: center;  
   vertical-align: middle; 
   position:fixed;
   width:100%;
}

你需要粘性页脚“对齐”你的意思是将页脚居中还是文本对齐?你能创建小提琴吗?并尝试添加
clear:both;保证金:0自动
#页脚中
。查看它是否已工作。
margin:0自动应该这样做吗?他的页脚是这样的?