如何在CSS中使用position属性定位伪选择器

k5hmc34c  于 2023-05-23  发布在  其他
关注(0)|答案(1)|浏览(156)

我想在div左边放置一个伪选择器(首字母)
我试着给父DIV位置Relative和pseduo选择器(div::first-letter)位置absolute,但没有成功

font-family: "Franklin Gothic Medium", "Arial Narrow", Arial, sans-serif;
  text-align: center;
  line-height: 55px;
  width: 300px;
  height: 60px;
  background-color: #d4d4d4;
  color: black;
  margin: auto;
  position: relative;
}

div::first-letter {
  position: absolute;
  top: 50px;
  left: 60px;
  color: white;
  left: 90px;
}
8wtpewkr

8wtpewkr1#

position不是可用于::first-letter的属性之一。一些可用的属性可用于推送文本,例如paddingline-height

相关问题