[英]How can I change the style of highlighted texts in the browser search result?
“ 查找”功能的結果無法更改-這是默認的用戶代理樣式,我認為沒有任何標准屬性允許您執行此操作。
您可以做的就是為您使用的瀏覽器設置它,或者與設置文本選擇顏色一樣多。
瀏覽器設定
如果您只想修改特定瀏覽器的樣式,請執行以下操作:
Firefox-在about:config
添加ui.textSelectBackgroundAttention
,並將其值設置為所需的顏色
Chrome-您沒有像Firefox這樣的任何隱藏設置,也無法更改AFAIK。
請注意,默認樣式也可能會從OS主題中選取查找突出顯示顏色。
文字選擇
但是,有一種樣式化文本選擇的方法 -您可以使用selection
psuedo元素 -請參見下面的演示:
.custom::selection { background: red; /* WebKit/Blink Browsers */ } .custom::-moz-selection { background: red; /* Gecko Browsers */ }
<div class="custom"> This is some text</div> <div>More text here</div>
使用::selection
,例如:
/* For other Browsers */
::selection {
background: red;
color: white;
}
/* For Firefox */
::-moz-selection {
background: red;
color: white;
}
看看下面的工作片段:
::-moz-selection { background: red; color: white; } ::selection { background: red; color: white; }
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nisi unde reprehenderit voluptas! Deserunt ducimus reiciendis necessitatibus adipisci obcaecati iste alias voluptate ratione ut at exercitationem, eum, dicta, excepturi eius suscipit.</p>
希望這可以幫助!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.