Browse Source

确保时间输入框的点击区域覆盖整个输入框

Boss
Default User 4 weeks ago
parent
commit
21c2410b20
  1. 100
      supply.html

100
supply.html

@ -671,6 +671,84 @@
border: 1px solid #d9d9d9;
border-radius: 4px;
font-size: 14px;
cursor: pointer;
width: 100%;
box-sizing: border-box;
/* 确保点击区域覆盖整个输入框 */
position: relative;
z-index: 1;
}
/* 确保日期输入框的日历图标覆盖整个输入框 */
.datetime-picker-group input[type="date"] {
/* 针对不同浏览器的样式调整 */
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
/* 针对WebKit浏览器(Chrome, Safari) */
.datetime-picker-group input[type="date"]::-webkit-calendar-picker-indicator {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 100%;
height: 100%;
cursor: pointer;
opacity: 0;
z-index: 2;
}
/* 针对Firefox浏览器 */
.datetime-picker-group input[type="date"]::-moz-calendar-picker-indicator {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 100%;
height: 100%;
cursor: pointer;
opacity: 0;
z-index: 2;
}
/* 确保时间输入框的时钟图标覆盖整个输入框 */
.datetime-picker-group input[type="time"] {
/* 针对不同浏览器的样式调整 */
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
/* 针对WebKit浏览器(Chrome, Safari) */
.datetime-picker-group input[type="time"]::-webkit-calendar-picker-indicator {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 100%;
height: 100%;
cursor: pointer;
opacity: 0;
z-index: 2;
}
/* 针对Firefox浏览器 */
.datetime-picker-group input[type="time"]::-moz-calendar-picker-indicator {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 100%;
height: 100%;
cursor: pointer;
opacity: 0;
z-index: 2;
}
/* 日期时间选择器底部 */
@ -2463,6 +2541,28 @@
// 添加到容器中
container.appendChild(picker);
// 为日期和时间输入框添加点击事件,确保点击整个输入框都能触发选择器
setTimeout(() => {
const dateInput = document.getElementById('pickerDate');
const timeInput = document.getElementById('pickerTime');
if (dateInput) {
dateInput.style.cursor = 'pointer';
dateInput.addEventListener('click', function(e) {
// 阻止事件冒泡,防止关闭选择器
e.stopPropagation();
});
}
if (timeInput) {
timeInput.style.cursor = 'pointer';
timeInput.addEventListener('click', function(e) {
// 阻止事件冒泡,防止关闭选择器
e.stopPropagation();
});
}
}, 0);
// 点击其他地方关闭选择器
document.addEventListener('click', function closePicker(e) {
if (!picker.contains(e.target) && e.target !== input && e.target !== input.nextElementSibling) {

Loading…
Cancel
Save