html - 在 :after pseudo element with css 添加弹出窗口

标签 html css popup pseudo-element

我很感兴趣,有一种方法可以在 :after 上添加一个小弹出框。当我悬停它时伪元素?有没有可能完全没有 HTML?我试图在网上搜索它,但似乎我总是需要某种 <span><div>标记中的元素以显示弹出文本。虽然我想用纯 CSS 来做。有什么技巧吗?

button::after {
  content: "i";
  color: blue;
}

button:hover::after {
  color: red;
  cursor: pointer;
  // add css to display popup
}

最佳答案

仅供演示。

试试这个:

<!DOCTYPE html>
<html>
<head>
<style>
.block{display:none;padding:20px;}
button::after {
  content: "i";
  color: blue;
  height:
}
button:hover::after {
  color: red;
  cursor: pointer;
}
button:hover~.block{display:block !important;background-color:red !important;}
</style>
</head>
<body>
    <button class="button"></button>
    <div class="block">Alert</div>
</body>
</html>

关于html - 在 :after pseudo element with css 添加弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45074788/

相关文章:

javascript - 仅在桌面模式下激活 jquery 功能?

css - 从 CSS 调整图像大小

css - 应用 div :nth-child to just the main div and not everything in it

css - 在整个行/列中对齐网格元素(就像 flex 元素一样)

javascript - 如何在弹出窗口中插入关闭按钮

javascript - 使用弹出栏的 Chrome 扩展

javascript - HTML 表格行的边框未显示在 js 弹出窗口中?

css - 使用 Bootstrap 的类在表内调整输入文本的大小

html - 网站的 PDF 到 HTML 转换

javascript - 按数据属性和父子关系对li进行排序