css控制某个div固定不动
原文:https://blog.csdn.net/qq_38422016/article/details/90067243
固定最常用的方法就是对其进行定位。 但在定位的时候需要注意:
- 如果想固定在屏幕的某处,那么确定被固定的元素的父元素是body;
- 为固定元素设置宽高。
比如给你的footer的class添加如下代码:
<style type="text/css">
.shopping_cart {
position: fixed;
left: 0;
bottom: 0;
width: 100%;
height: 60px;
background: #eee;
z-index: 10;
}
</style>
如顶部固定不动
<style type="text/css">
.editFrom { ----div的选择器
position: fixed; ----position样式
left: 0;
top: 0;
width: 100%;
height: 30%; ---div占用位置的高度
background: #eee;
z-index: 10;--折叠级别
}
</style>