2013-02-25 58 views
10

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」`的行爲改變了?

+0

必須使用引導CSS創建的jsfiddle似乎並沒有影響到Chrome的彈出 - HTTP: //jsfiddle.net/BxVDx/3/ – Kasaku 2013-02-25 15:49:04

+0

我剛剛通過Bootstrap的文檔和「插入」進入http://twitter.github.com/bootstrap/base-css.html#forms的默認表單示例。 – 2013-02-25 15:50:48

+1

@PirateKitten:我* *在你的小提琴中看到這個問題。我正在使用Chrome ....版本25.0.1364.97米。您? – 2013-02-25 15:52:16

回答

13

更新 鉻團隊接受了該錯誤並提交了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; 
} 

chrome 25 input[type="date"] defect hack-arounds

+1

+1用於打開Chrome的錯誤。 – 2013-02-27 15:17:18

+2

請注意,如果你正在浮動一個元素,它的顯示設置爲'block',所以沒有必要設置其他任何東西。請參閱[此CSS技巧文章](http://css-tricks.com/implied-block/),或者查看Chrome開發工具中計算的樣式。 說到這些工具,人們可能並不知道您可以轉到設置>元素>顯示Shadow DOM以查看此答案中引用的元素('-webkit-inner-spin-button'等)。 – CherryFlavourPez 2013-02-28 09:56:55

+0

Chrome版本26.0.1410.43 m再次正確顯示所有內容。 – 2013-04-01 21:33:04

6

更新

實測值問題

引導使用2樣式屬性..

1 - 顯示:內聯塊這使得谷歌打破箭頭到另一線

2 - height:20px會阻止您看到這個「線」

screenshot of findings

+0

我禁用「padding」時看到類似的更改。 – 2013-02-26 01:29:25

2

更新

谷歌Chrome問題被標記爲一個迴歸,所以這將有望儘快修復。 作爲臨時解決辦法,下面的工作:

input[type=date]::-webkit-calendar-picker-indicator { 
    display: inline-block; 
} 

這樣你就可以保持輸入顯示屬性設置爲任何你喜歡的一切工作之前一樣。

原始響應

設置display: -webkit-inline-flex(這似乎是<input type="date" />默認值)會解決這個問題,但是這可能會改變佈局,作爲輸入就像一個內聯元素處理。

這看起來像是一個bug,我會看看是否有人已經提交了一個錯誤報告,否則我會。

+1

鉻錯誤追蹤器存在一個問題,請隨時向其發送通知,以便在更新時收到通知,並表達您對此問題的興趣並獲得解決: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

+0

請參考我之前的評論:) – 2013-02-26 08:14:22

+0

Thanks @ximi 。我還打開了Bootstrap票證:http://github.com/twitter/bootstrap/issues/7061 – 2013-02-26 14:58:29

相關問題