关于固定定位position:fixed最简单、最直白的应用
position:fixed是啥?有啥用
position:fixed是固定定位的意思,就是把一个DIV(footer)固定在页面的最底部,无论页面上面的内容如何滚动,页面下部的(footer)不动。
要实现这个功能的时候百度了好多,但是也没看明白,把教程的代码拿过来仔细研究尝试才知道了,原来是这样,下面把代码贴出来,供自己和大家想用的时候来取吧!
<title></title>
<style>
.wrap{
width: 15rem;
background: #fff;
}
.item{
width: 100%;
height: 4rem;
background: #ff0;
margin-bottom: 0.4rem;
}
.btn{
width: 100%;
height: 2rem;
text-align: center;
background: #f00;
font-size: 1.8rem;
}
.posir{ position: relative;}/* 加在父级 */
.posif{ position: fixed;}/* 加在子级 */
.overf{overflow: auto;}/* 加在父级 */
.bottom{ bottom: 0;}/* 加在子级 */
</style>
</head>
<body>
<div class="wrap posir overf">
<div class="item"></div>
<div class="item"