.buttons {
  position: fixed;
  bottom: 0;
  width: 100%;
  background-color: #fff;
  padding: 10px;
  box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.1);
  text-align: center;
}

.cancel {
  background-color: #ccc;
  color: #fff;
  border: none;
  padding: 10px 20px;
  margin-right: 10px;
  cursor: pointer;
}

.confirm {
  background-color: #3f51b5;
  color: #fff;
  border: none;
  padding: 10px 20px;
  cursor: pointer;
}

在上面的代码中,我们使用了 position: fixedbottom: 0 来将按钮固定在屏幕底部。我们还添加了一些样式,如宽度、背景颜色、阴影和文本对齐等。最后,我们定义了取消和确定按钮的样式。

这样,无论页面滚动到哪里,这两个按钮都将保持在屏幕底部。

CSS 实现底部固定按钮 - 确定和取消按钮永远在屏幕底部

原文地址: https://www.cveoy.top/t/topic/nwRM 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录