Chrome中的日期輸入如<input type="date" name="due_date" id="due_date" min="2011-09-01" maxlength="10" class="span8">
用於允許用戶查看「彈出式」日曆以幫助選擇日期。我昨天注意到行爲已經停止;輸入只允許用戶上/下日期部分(月/日/年)。我訪問了Chrome博客並進行了Google搜索,但找不到任何此類更改。 爲什麼input type="date"
的行爲改變了?奇怪的是,這種變化似乎僅限於Bootstrap,因爲http://www.w3schools.com/html/tryit.asp?filename=tryhtml5_input_type_date仍然展示日期選擇器。爲什麼`input type =「date」`的行爲改變了?
回答
更新 鉻團隊接受了該錯誤並提交了patch back to WebKit。 變化的要點是日期控件將在靈活的框元素內呈現,而不管應用於輸入[type ='date']控件的樣式。
我是一個that reported the defect referenced here to Chromium。一個建議的解決方案是應用display:inline-block;到日曆選擇器:
input[type="date"]::-webkit-calendar-picker-indicator{
display:inline-block;
}
然而,這是一個靠不住解決方案,因爲該控件仍然轉移到比在輸入[類型=「日期」]控制右對齊之外的位置。
另一種選擇是浮動右:
input[type="date"]::-webkit-calendar-picker-indicator {
display:inline-block;
margin-top:2%;
float:right;
}
input[type="date"]::-webkit-inner-spin-button {
display:inline-block;
float:right;
}
這具有反相旋轉器和日曆選擇器控制的副作用。
最好的黑客,我認爲是去除微調和浮動權:
input[type="date"]::-webkit-calendar-picker-indicator{
display:inline-block;
margin-top:2%;
float:right;
}
input[type="date"]::-webkit-inner-spin-button {
/* display: none; <- Crashes Chrome on hover */
-webkit-appearance: none;
margin: 0;
}
+1用於打開Chrome的錯誤。 – 2013-02-27 15:17:18
請注意,如果你正在浮動一個元素,它的顯示設置爲'block',所以沒有必要設置其他任何東西。請參閱[此CSS技巧文章](http://css-tricks.com/implied-block/),或者查看Chrome開發工具中計算的樣式。 說到這些工具,人們可能並不知道您可以轉到設置>元素>顯示Shadow DOM以查看此答案中引用的元素('-webkit-inner-spin-button'等)。 – CherryFlavourPez 2013-02-28 09:56:55
Chrome版本26.0.1410.43 m再次正確顯示所有內容。 – 2013-04-01 21:33:04
更新
實測值問題
引導使用2樣式屬性..
1 - 顯示:內聯塊這使得谷歌打破箭頭到另一線
2 - height:20px會阻止您看到這個「線」
我禁用「padding」時看到類似的更改。 – 2013-02-26 01:29:25
更新
谷歌Chrome問題被標記爲一個迴歸,所以這將有望儘快修復。 作爲臨時解決辦法,下面的工作:
input[type=date]::-webkit-calendar-picker-indicator {
display: inline-block;
}
這樣你就可以保持輸入顯示屬性設置爲任何你喜歡的一切工作之前一樣。
原始響應
設置display: -webkit-inline-flex
(這似乎是<input type="date" />
默認值)會解決這個問題,但是這可能會改變佈局,作爲輸入就像一個內聯元素處理。
這看起來像是一個bug,我會看看是否有人已經提交了一個錯誤報告,否則我會。
鉻錯誤追蹤器存在一個問題,請隨時向其發送通知,以便在更新時收到通知,並表達您對此問題的興趣並獲得解決:https://code.google.com/p/chromium/issues/detail ?can = 2&start = 0&num = 100&q = date%20picker&colspec = ID%20Pri%20Mstone%20ReleaseBlock%20OS%20Area%20Feature%20Status%20Owner%20Summary&groupby =&&sort =&id = 178175 – ximi 2013-02-26 07:50:02
請參考我之前的評論:) – 2013-02-26 08:14:22
Thanks @ximi 。我還打開了Bootstrap票證:http://github.com/twitter/bootstrap/issues/7061 – 2013-02-26 14:58:29
- 1. 爲什麼TYPE DATE出錯?
- 2. date - insert into - from input type =「date」
- 3. 有沒有辦法使用CSS將input type =「text」更改爲「date」?
- 4. 驗證<input type =「date」>
- 5. HTML5 <input type =「date」> change
- 6. 爲什麼HTML5中沒有<input type =「picture」>和/或<input type =「video」>?
- 7. 爲什麼用<input type = submit button error out改變字體大小?
- 8. ExpandoObject - 爲什麼Type的行爲不同?
- 9. 爲什麼GetKeyState改變了ToUnicodeEx的行爲?
- 10. input type =「date」text-align:right IOS設備
- 11. <input type =「date」/>使用新日期
- 12. Angular2 material md-input type =「date」not in IE 11
- 13. 使用jQuery計算<input type =「date」
- 14. ReactJS <input type =「date」>格式日期
- 15. 爲什麼編碼改變了?
- 16. issubclass(type,type)=爲什麼?
- 17. 更改<input type =「date」/>指令中的語言
- 18. input type =「url」爲相對URL
- 19. 爲<input type ='submit'>
- 20. DateField未呈現爲type =「date」
- 21. 爲什麼在Rails 3中這個erb行爲改變了?
- 22. <input type =「checkbox」/>爲什麼meteor.js中的斜線指導?
- 23. 爲什麼YEAR 7字符的html input type =「datetime-local」值長?
- 24. 爲什麼我的<input type =「submit」>不顯示?
- 25. 爲什麼IE8中的<input type =「file」>框灰色?
- 26. C++爲什麼指針值改變了?
- 27. 爲什麼構造函數改變了?
- 28. <INPUT TYPE =「文件」>,改變價值
- 29. 改變<INPUT TYPE =文件「>價值
- 30. input [type =「submit」] - 點擊後改變背景
必須使用引導CSS創建的jsfiddle似乎並沒有影響到Chrome的彈出 - HTTP: //jsfiddle.net/BxVDx/3/ – Kasaku 2013-02-25 15:49:04
我剛剛通過Bootstrap的文檔和「插入」進入http://twitter.github.com/bootstrap/base-css.html#forms的默認表單示例。 – 2013-02-25 15:50:48
@PirateKitten:我* *在你的小提琴中看到這個問題。我正在使用Chrome ....版本25.0.1364.97米。您? – 2013-02-25 15:52:16