CSS以选择/样式第一个单词 [英] CSS to select/style first word
问题描述
这让我有些难过.我想在#content div中将所有段落的第一个单词设为14pt,而不是默认的段落(12pt).有没有办法在纯CSS中做到这一点,还是我将第一个单词包裹在一个跨距中来完成此操作?
This one has me kind of stumped. I want to make the first word of all the paragraphs in my #content div at 14pt instead of the default for the paragraphs (12pt). Is there a way to do this in straight CSS or am I left wrapping the first word in a span to accomplish this?
推荐答案
您要查找的是不存在的伪元素.有:first-letter和:first-line,但没有:first-word.
What you are looking for is a pseudo-element that doesn't exist. There is :first-letter and :first-line, but no :first-word.
您当然可以使用JavaScript进行此操作.这是我发现的一些执行此操作的代码: http://www.dynamicsitesolutions.com/javascript/first-word-selector/
You can of course do this with JavaScript. Here's some code I found that does this: http://www.dynamicsitesolutions.com/javascript/first-word-selector/
这篇关于CSS以选择/样式第一个单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!