How to Capitalize first letter only using CSS in each case

后端 未结 5 1831
礼貌的吻别
礼貌的吻别 2021-02-13 04:10

I want to Capitalize first letter only and other should be small using CSS

String is:

SOMETHING BETTER 
sOMETHING bETTER
Something bett         


        
5条回答
  •  情歌与酒
    2021-02-13 04:57

    It is not possible with CSS alone but you can do it with Javascript or PHP for example.

    In PHP

    ucwords()
    

    And in Javascript

    function toTitleCase(str){
        return str.replace(/\w\S*/g, function(txt){
            return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
    }
    

    Extracted from Convert string to title case with JavaScript

提交回复
热议问题