css - 如何在 css 中制作自定义高亮显示?

标签 css highlight underline

enter image description here

^ 类似的东西 - 它使用 :after 吗? (无法对多行执行此操作)

.home-about h3:after{
 margin-top:-15px;
 content: " ";
 background:#d7edf4;
 z-index: 0;
}

最佳答案

是的,您可以使用伪元素。这是一种绝对定位在 h3 中且具有负 z-index 的方法。

h3 {
  position: relative;
  display: inline-block;
}

h3:after {
  content: " ";
  background: #d7edf4;
  z-index: -1;
  display: block;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: .4em;
}
<h3>text</h3>

关于css - 如何在 css 中制作自定义高亮显示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43622673/

相关文章:

javascript - CSS/HTML/JS 用下拉搜索预览排列 div

html - 通过表格对齐表单中的文本和下拉列表

jquery - CSS - 创建一个滚动条来控制一个单独的 DIV

grid - ExtJs/Sencha : how to highlight a grid row after insert?

html - 停止突出显示 HTML 文本

css - 线性渐变边框底部不起作用

html - Iframe 不会在 iexplore 8-11、wordpress 中加载

android - 突出显示 ListView 选定的行

css - 如何消除非链接网址上的下划线?

android - 以编程方式设置 editText 突出显示颜色