如何使用 CSS 中的位置属性定位伪选择器

问题描述 投票:0回答:1

我想在 div 左边放置一个伪选择器(第一个字母)

我尝试给父 DIV 位置 Relative 和 pseduo 选择器 ( div::first-letter ) position 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;
}
html css
1个回答
0
投票

position
不是可与 ::first-letter
 一起使用的 
属性之一。一些可用的属性可用于推动文本,例如
padding
line-height
.

© www.soinside.com 2019 - 2024. All rights reserved.