/* 确保搜索框和新增按钮固定在顶部 */ .top { position: sticky; /* 使搜索框在页面滚动时固定 */ top: 0; /* 固定在顶部 */ z-index: 100; /* 确保在表格之上 */ background-color: #f7f7f7; /* 背景色 */ padding: 2% 0; /* 上下内边距 */ } .topsearch { width: 90%; margin-left: 5%; display: flex; align-items: center; justify-content: space-between; /* 确保搜索框和按钮分开 */ } .frame { background-color: white; width: 75%; border-radius: 20rpx; padding: 0 3%; } .frame > input { font-size: 24rpx; margin: 6rpx 0; } .topsearch > text { width: 10%; margin-left: 5%; color: #a8a7a7fa; } /* 新增按钮容器 */ .add-btn-container { position: sticky; top: 0; background-color: #fff; /* 背景色为白色 */ z-index: 101; /* 确保新增按钮高于表格 */ padding: 10rpx; /* 增加按钮的上内边距 */ display: flex; justify-content: center; margin-top: 10rpx; /* 新增按钮的上边距 */ } /* 新增按钮 */ .add-btn { padding: 5px 12px; background-color: #007aff; color: #fff; border-radius: 4px; font-size: 14px; } /* 表格容器 */ .table-container { width: 100%; overflow-x: auto; /* 启用横向滚动 */ background-color: #fff; border: 1rpx solid #ddd; margin-top: 20rpx; /* 添加上边距,确保不会和顶部元素重叠 */ white-space: nowrap; /* 禁止换行 */ } /* 表头样式 */ .table-header { display: flex; width: max-content; background-color: #FFD700; font-weight: bold; border-bottom: 1rpx solid #ddd; z-index: 99; /* 确保表头高于表格内容 */ } /* 表格单元格样式 */ .table-cell { flex: none; width: 250rpx; padding: 10rpx; text-align: center; font-size: 28rpx; color: #333; border-right: 1rpx solid #ddd; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } /* 表格内容样式 */ .table-body { display: flex; flex-direction: column; width: max-content; } .table-row { display: flex; } .table-row:nth-child(odd) { background-color: #f9f9f9; } .table-row:nth-child(even) { background-color: #ffffff; } /* 模态框背景 */ .modal { position: fixed; /* 固定定位,始终在屏幕中央 */ top: 0; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; align-items: center; background-color: rgba(0, 0, 0, 0.6); /* 半透明背景色,增加一点深度感 */ z-index: 1000; /* 提高层级,确保模态框在其他元素之上 */ } /* 模态框内容 */ .modal-content { background-color: #fff; /* 模态框内容背景为白色 */ border-radius: 16px; /* 圆角 */ width: 80%; /* 宽度占80% */ max-width: 500rpx; /* 最大宽度限制 */ box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1); /* 添加阴影效果,增加浮动感 */ padding: 20rpx; /* 内边距 */ transition: transform 0.3s ease-out; /* 平滑的动画过渡 */ } /* 每个选项项 */ .modal-item { text-align: center; /* 每个项的文本居中 */ font-size: 32rpx; /* 字体大小 */ padding: 20rpx 0; /* 内边距 */ border-top: 1rpx solid #eee; /* 上边框为浅灰色 */ cursor: pointer; /* 鼠标悬停时显示为手指 */ transition: background-color 0.2s; /* 添加鼠标悬停的平滑过渡 */ } /* 第一项不显示上边框 */ .modal-item:first-child { border-top: none; } /* 提交按钮样式 */ .submit-btn { background-color: #4CAF50; /* 绿色背景 */ color: white; /* 白色字体 */ border: none; /* 去掉边框 */ padding: 10rpx 20rpx; /* 内边距 */ font-size: 32rpx; /* 字体大小 */ border-radius: 8rpx; /* 圆角 */ cursor: pointer; /* 鼠标悬停时显示为手指 */ transition: background-color 0.3s ease; /* 背景色变化平滑过渡 */ } /* 提交按钮悬停效果 */ .submit-btn:hover { background-color: #45a049; /* 悬停时变为更深的绿色 */ } /* 取消按钮样式 */ .cancel-btn { background-color: #e74c3c; /* 红色背景 */ color: white; /* 白色字体 */ border: none; /* 去掉边框 */ padding: 10rpx 20rpx; /* 内边距 */ font-size: 32rpx; /* 字体大小 */ border-radius: 8rpx; /* 圆角 */ cursor: pointer; /* 鼠标悬停时显示为手指 */ transition: background-color 0.3s ease; /* 背景色变化平滑过渡 */ } /* 取消按钮悬停效果 */ .cancel-btn:hover { background-color: #c0392b; /* 悬停时变为更深的红色 */ } /* 新增数据弹窗的按钮容器 */ .modal-content { display: flex; flex-direction: column; /* 默认垂直方向布局 */ align-items: center; /* 居中对齐内容 */ } /* 按钮容器 */ .button-container { display: flex; /* 使用 flexbox 布局 */ justify-content: space-between; /* 按钮之间均匀分布 */ width: 100%; /* 按钮容器宽度为 100% */ margin-top: 20rpx; /* 上边距 */ } /* 每个按钮样式 */ .submit-btn, .cancel-btn { flex: 1; /* 使按钮宽度相等 */ margin: 0 10rpx; /* 按钮间隔 */ }