input type=date 然后 datepicker 图标没有出现在 Firefox 上
input type=date then datepicker Icon is not appearing on Firefox
在 Firefox 上,我遇到了一个问题,即日期选择器图标没有出现在文本框中,而它出现在 Chrome 和 Edge 上。
以下是代码行和屏幕截图,请检查并让我知道在 firefox 上显示的方式是什么
<input type="date" required="required" class="formInput">
on chrome icon appears as in this image
on Edge icon appears as in this image
*on Firefox icon disappears as in this image*
输入UI取决于浏览器more info。
您可以使用 jQuery 实现自定义设计(因此它在所有浏览器中始终显示相同)。 Like here.
Firefox 不会那样做,但是我会这样做:
div外的输入是针对其他浏览器的。 div 里面的那个是 firefox 的。我使用 JS 来检测浏览器并相应地采取行动,隐藏每个浏览器。
请注意,您需要为您的 img 源下载日历图标。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div class="firefox" style="border: 1px solid #DDD; width:max-content;">
<input style="border: none;" type="date" id="start" name="trip-start" value="2018-07-22" min="2018-01-01"
max="2018-12-31">
<img src="calendar.png" style="width:15px; padding:10px 15px 0px 0px" />
</div>
<input class="anotherBrowser" style="border: none;" type="date" id="start" name="trip-start" value="2018-07-22"
min="2018-01-01" max="2018-12-31">
<script>
// Detect Firefox 1.0+
var isFirefox = typeof InstallTrigger !== 'undefined';
//Hide
if (isFirefox) {
document.querySelector(".anotherBrowser").style.display = "none";
} else {
document.querySelector(".firefox").style.display = "none";
}
</script>
</body>
</html>
当我们使用 input type="date" 时,我能够解决日期选择器图标在输入文本框中消失的问题。它适用于 Chrome、Firefox、Edge。
以下是我在 divs
上使用和应用的 css
.cal-wrp {
position: relative;
background-color: white;
margin-bottom: 16px;
}
.btnCal-wrp {
display: inline-block;
width: 100%;
position: relative;
z-index: 10;
}
.btnCal-click {
border: 0.0625rem solid #cfd0d3;
background-color: transparent;
width: 100%;
padding: 0.75rem;
cursor: pointer;
border-radius: 0;
font-size: 0.875rem;
line-height: 1.4;
}
.btnCal-click::-webkit-calendar-picker-indicator {
right: -10px;
position: absolute;
width: 78px;
height: 40px;
color: rgba(204, 204, 204, 0);
opacity: 0;
}
.btnCal-click::-webkit-inner-spin-button {
-webkit-appearance: none;
}
.btnCal-click::-webkit-clear-button {
margin-right: 75px;
}
.btnCal {
background: transparent;
border: none;
color: black;
padding: 13px;
position: absolute;
right: 0;
top: 0;
}
日历文本框代码:
<div class="cal-wrp">
<div class="btnCal-wrp">
<input class="btnCal-click" type="date" required>
</div>
<button class="btnCal"><span class="fa fa-calendar"></span></button>
</div>
在 Firefox 上,我遇到了一个问题,即日期选择器图标没有出现在文本框中,而它出现在 Chrome 和 Edge 上。 以下是代码行和屏幕截图,请检查并让我知道在 firefox 上显示的方式是什么
<input type="date" required="required" class="formInput">
on chrome icon appears as in this image
on Edge icon appears as in this image
*on Firefox icon disappears as in this image*
输入UI取决于浏览器more info。
您可以使用 jQuery 实现自定义设计(因此它在所有浏览器中始终显示相同)。 Like here.
Firefox 不会那样做,但是我会这样做:
div外的输入是针对其他浏览器的。 div 里面的那个是 firefox 的。我使用 JS 来检测浏览器并相应地采取行动,隐藏每个浏览器。
请注意,您需要为您的 img 源下载日历图标。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div class="firefox" style="border: 1px solid #DDD; width:max-content;">
<input style="border: none;" type="date" id="start" name="trip-start" value="2018-07-22" min="2018-01-01"
max="2018-12-31">
<img src="calendar.png" style="width:15px; padding:10px 15px 0px 0px" />
</div>
<input class="anotherBrowser" style="border: none;" type="date" id="start" name="trip-start" value="2018-07-22"
min="2018-01-01" max="2018-12-31">
<script>
// Detect Firefox 1.0+
var isFirefox = typeof InstallTrigger !== 'undefined';
//Hide
if (isFirefox) {
document.querySelector(".anotherBrowser").style.display = "none";
} else {
document.querySelector(".firefox").style.display = "none";
}
</script>
</body>
</html>
当我们使用 input type="date" 时,我能够解决日期选择器图标在输入文本框中消失的问题。它适用于 Chrome、Firefox、Edge。 以下是我在 divs
上使用和应用的 css .cal-wrp {
position: relative;
background-color: white;
margin-bottom: 16px;
}
.btnCal-wrp {
display: inline-block;
width: 100%;
position: relative;
z-index: 10;
}
.btnCal-click {
border: 0.0625rem solid #cfd0d3;
background-color: transparent;
width: 100%;
padding: 0.75rem;
cursor: pointer;
border-radius: 0;
font-size: 0.875rem;
line-height: 1.4;
}
.btnCal-click::-webkit-calendar-picker-indicator {
right: -10px;
position: absolute;
width: 78px;
height: 40px;
color: rgba(204, 204, 204, 0);
opacity: 0;
}
.btnCal-click::-webkit-inner-spin-button {
-webkit-appearance: none;
}
.btnCal-click::-webkit-clear-button {
margin-right: 75px;
}
.btnCal {
background: transparent;
border: none;
color: black;
padding: 13px;
position: absolute;
right: 0;
top: 0;
}
日历文本框代码:
<div class="cal-wrp">
<div class="btnCal-wrp">
<input class="btnCal-click" type="date" required>
</div>
<button class="btnCal"><span class="fa fa-calendar"></span></button>
</div>