L&Z's blog L&Z's blog
主页
  • HTML
  • CSS
  • JS
  • TS
  • Vue
  • Node
  • Markdown
  • Yaml
  • HTML
  • CSS
  • JS
  • TS
  • Vue
  • Node
  • 小程序
  • 博客
  • 工作
  • VSCode
  • Browser
  • Npm
  • Git
  • GitHub
  • 友链
  • 收藏
  • 足迹
  • 记录
  • 抽奖
  • 错 or 对
  • 分类
  • 标签
  • 归档
关于
GitHub (opens new window)

L&Z

主页
  • HTML
  • CSS
  • JS
  • TS
  • Vue
  • Node
  • Markdown
  • Yaml
  • HTML
  • CSS
  • JS
  • TS
  • Vue
  • Node
  • 小程序
  • 博客
  • 工作
  • VSCode
  • Browser
  • Npm
  • Git
  • GitHub
  • 友链
  • 收藏
  • 足迹
  • 记录
  • 抽奖
  • 错 or 对
  • 分类
  • 标签
  • 归档
关于
GitHub (opens new window)
  • CSS

    • 常用css
    • 图片未加载前自动撑开元素高度
    • 水平垂直居中的几种方式
    • 如何根据系统主题自动响应CSS深色模式
    • 使用hover和attr()定制悬浮提示
      • attr()
    • CSS给table的tbody添加滚动条
    • CSS3之animation动画
  • JS

  • Vue

  • Node

  • 小程序

  • 博客搭建

  • 工作

  • 笔记
  • CSS
lz
2022-04-18
目录
attr()

使用hover和attr()定制悬浮提示

# attr()

注意

目前只支持content属性

<html>
<p class="demo-attr" data-title="张三"></p>
</html>
<style>
.demo-attr{
  position: relative;
  padding: 2px;
  border: 2px solid #99c2ec;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  background-clip: content-box;
  cursor: pointer;
  transition: all 300ms;
  background-color:#99c2ec;
  margin: 30px;
}
.demo-attr::before,
.demo-attr::after {
  position: absolute;
  left: 50%;
  bottom: 100%;
  opacity: 0;
  transform: translate3d(0, -30px, 0);
  transition: all 300ms;
}
.demo-attr::before {
  margin: 0 0 12px -35px;
  border-radius: 5px;
  width: 70px;
  height: 30px;
  background-color: rgba(0,0,0, .5);
  line-height: 30px;
  text-align: center;
  color: #fff;
  content: attr(data-title);
}
.demo-attr::after {
  margin-left: -6px;
  border: 6px solid transparent;
  border-top-color: rgba(0,0,0, .5);
  width: 0;
  height: 0;
  content: "";
}
.demo-attr:hover::before,.demo-attr:hover::after {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}
</style>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
编辑 (opens new window)
#CSS
上次更新: 2023/03/08, 02:53:55
如何根据系统主题自动响应CSS深色模式
CSS给table的tbody添加滚动条

← 如何根据系统主题自动响应CSS深色模式 CSS给table的tbody添加滚动条→

最近更新
01
nodejs递归读取所有文件
12-15
02
vue3响应式原理
09-20
03
原生js实现jquery中siblings效果
09-20
更多文章>
Theme by Vdoing | Copyright © 2021-2025 L&Z |
  • 跟随系统
  • 浅色模式
  • 深色模式