我在锚标记之前使用:before并添加了一些使用 CSS 属性的内容。content我想将此内容放在锚标签上方,但在锚标签上应用填充时会遇到一些定位问题。请检查 jsbin 演示以使事情清楚。
在 JSBIN 检查
这是我的 CSS 代码
ul {
  margin-top:200px;
  list-style-type: none;
}
li {
  height: 100px;
}
a {
  outline: 4px solid skyblue;
}
a:before {
  content: "top place";
  background-color: blue;
  color: white;
  padding: 5px;
  border-top-left-radius: 2px;
  border-top-right-radius: 2px;
  font-size: 14px;
  
  /* To move it to top of anchor element*/
  position: absolute;
  margin-top: -30px;
  margin-left: -4px;
}
.b {
  padding: 40px;
}