对于移动端会有这种情况:上方查询输入框,中间列表时长时短,底部执行按钮
。此时需要按钮浮于列表之上,以防被挤下去。
1、margin:auto
.center{
position: absolute;
left: 0;
right: 0;
top: 0; bottom: 0;// 只要左右居中可以不加top、bottom
// bottom: 30px; 可以另外设置想要的上下位置
margin: auto;
}
2、transform: translate(-50%, -50%)
.center{
position: absolute;
left: 50%;
top: 50%; // 只要左右居中可以不加top
// bottom: 30px; 可以另外设置想要的上下位置
transform: translate(-50%, -50%); /* 50%为自身尺寸的一半 */
}