gpt4 book ai didi

html - 我怎样才能使CSS :first-letter that isn't mark-up/HTML tag function?

转载 作者:可可西里 更新时间:2023-11-01 13:38:19 24 4
gpt4 key购买 nike

很简单,我需要在 <p> 中创建第一个字母是不同的颜色,但有时在那个字母之前有一个图像。有没有办法制作:first-letter应用于非 HTML 标记?

CSS:

p:first-letter {
color: red; // this should make the "W" red"
}

HTML:

<p><img src="will.jpg">West Philadelphia, Born And Raised</p>

最佳答案

用 CSS 是不可能的。您需要按照建议更改 HTML 或执行一些 javascript hack:

  • 找到段落的第一个 child img 元素
  • 将它们移到段落末尾
  • 对它们应用样式定义以显示在文本之前

关于html - 我怎样才能使CSS :first-letter that isn't mark-up/HTML tag function?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10813015/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com