CSS 来选择/设置第一个单词的样式 [英] CSS to select/style first word

查看:44
本文介绍了CSS 来选择/设置第一个单词的样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个让我有点难受.我想将 #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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆