zoukankan      html  css  js  c++  java
  • 页面底部固定

    效果如图:

    代码:

    			html,
    			body {
    				 100%;
    				height: 100%;
    				min-height: 100%;
    			}
    			.container {
    				position: relative;
    				height: auto;
    				min-height: 100%;  //关键的一行代码
    				margin: 0;
    				
    			}
    			
    			.container .header {
    				height: 100px;
    				background: #0000FF;
    			}
    			.container .push {
    				padding-bottom: 100px;
    			}
    			.footer {
    				position: relative;
    				height: 100px;
    				margin-top: -100px;
    				background: #0000FF;
    				border: #0000FF 1px solid;
    			}
    
                    //DOM
    		<div class="container">
    			<div class="header">
    				<p>头部文本</p>
    			</div>
    			<div class="content">
    				<p>主体内容</p>
    			</div>
    			
    		</div>
    		<div class="footer">
    			<p>底部文本</p>
    		</div>
    

    补充知识点:

    当元素没有内容时候,设置height:100%,该元素不会被撑开,此时高度为0,

    但是设置height:100vh,该元素会被撑开屏幕高度一致。

     

  • 相关阅读:
    rt_list_entry() 函数
    替换空格
    跳台阶
    斐波那契数列
    基于5221码的同步十进制加法计数器
    强连通分量+Tarjia+缩点
    次小生成树
    差分约束
    P1547 Out of Hay
    P1197 [JSOI2008]星球大战
  • 原文地址:https://www.cnblogs.com/cuipingzhao/p/15467081.html
Copyright © 2011-2022 走看看