2016-05-30 32 views
5

我在iPhone設備上使用Safari時遇到了一個小的CSS問題。我的搜索輸入爲藍色,當用戶專注於它,插入符號幾乎是無形的:iOS Safari瀏覽器輸入插入符號的顏色

Caret

在所有桌面瀏覽器,它有正確的顏色(白色),甚至在桌面上的Safari。任何想法如何解決這個問題,並改變在iOS設備上的符號顏色?

輸入風格:

input { 
    background-color: $stateBlue; 
    height: $navbarItemHeight; 
    padding: 0 10px; 
    vertical-align: bottom; 
    color: $white; 
    border-radius: $borderRadius; 
    font-size: 1.1666666667em; // 16px 
    -moz-appearance:none; 
    -webkit-appearance:none; 

    &::-webkit-input-placeholder { 
    text-shadow: none; 
    -webkit-text-fill-color: initial; 
    } 
} 
+0

你是否設法解決這個問題?我有同樣的問題。 –

+1

並非如此,似乎無法通過本機iOS設備中的CSS。 – Pawel

+0

謝謝。我最終實現了我自己的脫口秀。 –

回答

2

有這個叫做caret-color一個W3C specification它可以這樣使用:

input[type="text"].custom { 
 
    caret-color: red; 
 
}
<div> 
 
    <label>default caret:</label> 
 
    <input type="text"/> 
 
</div> 
 
<div> 
 
    <label>custom red caret:</label> 
 
    <input type="text" class="custom"/> 
 
</div>

這是currently supported通過瀏覽器(同樣適用於Android ),Firefox和Opera。也許是好消息:Safari似乎也支持它,因爲它的技術預覽版本,所以也許iOS Safari會隨之而來。

相關問題