attr() 使用 html 属性值 .tech-item:hover::after { content: attr(data-title); position: absolute; top: -10px; left: 20px; z-index: 1000; text-align: center; width: max-content; background: #f00; color: #fff; padding: 0 6px; height: 25px; line-height: 25px; font-size: 12px; }