CSS for changing color of last word in h1

前端 未结 10 2440
遇见更好的自我
遇见更好的自我 2020-11-29 09:31

I have a website that I am developing using CSS3 and I have h1 tag for the title:

main title

Now I want t

10条回答
  •  Happy的楠姐
    2020-11-29 09:58

    "last-word" won't work on every browser; for instance, it doesn't work with Safari. I wouldn't use the accepted answer. I don't think it's a good idea to import an entire library or plugin just to change the last word of a single title, it's like "killing a bug with a cannon"... Instead I would use a single Javascript function, and a global class. Something like this:

    This is my awesome title

    CSS:

    
    

    Initially, you would have something like this:

    This is my awesome title

    Then, you could initialize a Javascript method to change the last word on $(document).ready() =>

    
    

    Good luck.

提交回复
热议问题