css - 如何使用CSS突出显示选定的文本?

标签 css styles

如何像按钮一样突出显示所选的文本之一,例如我需要使用 css 将其突出显示在屏幕上

enter image description here

任何人都可以帮助我提供解决方案或链接以共享任何信息。

最佳答案

这就是您可以使用 CSS 在 html 中突出显示文本的方法。当您拖动文本时,文本将突出显示

<head>
<style>
::-moz-selection { /* Code for Firefox */
    color: red;
    background: yellow;
}

::selection {
    color: red;
    background: yellow;
}
</style>
</head>
<body>

<h1>Select some text on this page:</h1>

<p>This is a paragraph.</p>
<div>This is some text in a div element.</div>

<p><strong>Note:</strong> ::selection is not supported in Internet Explorer 8 and earlier versions.</p>
<p><strong>Note:</strong> Firefox supports an alternative, the ::-moz-selection property.</p>

</body>
</html>

关于css - 如何使用CSS突出显示选定的文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51173595/

相关文章:

wpf - 在哪里可以找到 native WPF 控件的 Generic.xaml?

html - 从div的底部绝对定位

css - 如何实现新的 Material Design Bottom App Bar

css - 即使在 app.js 中导入样式后,Ionic React 样式也不会呈现

WPF - 如何在聚焦时突出显示组合框边框

npm - 如何在 VS Code 中设置 Airbnb ESLint?

wpf - 我可以在不知道绑定(bind)本身的情况下更改 DataTrigger 中绑定(bind)的属性吗?

javascript - 用于更改背景图像的多状态动画按钮

jquery - 在滑动细节之前,向下/向上滑动不太顺畅,细节和缩略图相关

html - 如何 overflow hidden 设置为滚动的父级的边框半径?