change First letter of word font size with javascript/jquery

孤者浪人 提交于 2020-01-16 01:06:29

问题


Is there a way to select the first letter of each word with either javascript or jQuery?

Im trying to make tags on my page have the first letter of each word be a bigger font size. Im assuming it involves regular expressions but all i keep finding are things for form validation. I also see a bunch of stuff for capitalizing the first word. I'm trying to change the font size.

Does anyone know if this can be done and how? Thanks.


回答1:


If you are just looking for a styling change, you might be able to get away with pure CSS using :first-letter.

Here's an example: http://jsfiddle.net/bgNP3/1/

Note: I apparently had to make the spans into inline-blocks for the effect to work.

Update fixed link to jsfiddle.




回答2:


You could try using:

  • letteringjs its may be a little more complex than what you need tho, or
  • you could use this Is there any clean CSS method to make each letter in a word a different color?


来源:https://stackoverflow.com/questions/6991488/change-first-letter-of-word-font-size-with-javascript-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!