如何在每种情况下仅使用CSS大写首字母

如何在每种情况下仅使用CSS大写首字母

问题描述:

我只想使用首字母大写,而其他则应该小写,使用CSS

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

字符串为:

SOMETHING BETTER 
sOMETHING bETTER
Something better

,但结果应该是

Something Better

是否可以使用CSS?要大写第一个字母,我使用

Is this possible using CSS? To Capitalize first letter I am using

text-transform: capitalize;

但无法在每种情况下都大写。
我想使用CSS,因为它在我的应用程序中已经编写了所有经过硬编码的地方,但是到处都调用了一个类。

But not able to capitalize in each case. "I want to use CSS because in my application it has written every where hard coded but a class has been called everywhere."

您应该可以使用:第一个字母伪元素:

you should be able to use the :first-letter pseudo element:

.fl {
 display: inline-block;
}

.fl:first-letter {
 text-transform:uppercase;
}

<p>
 <span class="fl">something</span> <span class="fl">better</span>
</p>

收益率:

更好的东西