2015-10-19 74 views
1

当我打开模式窗口时,textarea中的onfocus文本值以蓝色突出显示。我不确定应该使用什么CSS属性从文本中删除突出显示的onfocus蓝色。我尝试了下面,但它不起作用。删除焦点上的蓝色突出显示的文本

input[type="text"], textarea{ 
    outline: none; 
    box-shadow:none !important; 
    border:1px solid #ccc !important; 
} 

Text filed value highlighted in blue

+0

尝试了这一点':重点{大纲:无;}'http://stackoverflow.com/questions/2943548/best-way-to-reset-remove-chromes-input -highlighting对焦边界 – FBHY

回答

0

您可以使用user-select避免任何文本的选择

input { 
 
    -webkit-user-select: none; /* Chrome all/Safari all */ 
 
    -moz-user-select: none;  /* Firefox all */ 
 
    -ms-user-select: none;  /* IE 10+ */ 
 
    user-select: none;   /* Likely future */  
 
}
<input type="text">

要小心,因为你避免选择提示用户,并导致可访问性丢失。

0

user-select属性suggested by Marcos一种替代方法是使用::selection::-moz-selection上自己的规则)以特异性设置/取消的颜色/所选文本的背景(无需禁用选择功能)。

input[type="text"]::selection, 
 
textarea::selection { 
 
    background-color: inherit; 
 
    color: red; 
 
} 
 
input[type="text"]::-moz-selection, 
 
textarea::-moz-selection { 
 
    background-color: inherit; 
 
    color: red; 
 
} 
 

 
input[type="text"], 
 
textarea { 
 
    outline: none; 
 
    box-shadow: none !important; 
 
    border: 1px solid #ccc !important; 
 
}
<input type="text" value="test value for selection" /> 
 
<hr/> 
 
<textarea>test text for selection</textarea>

相关问题