我有一句话是全部在大写锁定中(并且不能更改)。这句话是段落的一部分,仅使用 CSS(如果需要,也可以使用一点 Jquery)。我怎样才能始终在大多数设备上可靠地获得结果!
注:我看过问题such as this , 但它们不包括多句因素。
无变化:
THIS IS THE FIRST SENTENCE. And this is the second, as it is from the server.
期望的结果:
This is the first sentence. And this is the second...
我试过的 CSS 是这样的,但它不适用于多个句子。
p { text-transform: lowercase;}
p:first-letter {text-transform:capitalize}
最佳答案
似乎是 jQuery 的问题。检查这个答案的整个元素大写,然后你可以使用类似的东西来解析第一句话:
var setval = $('#my_paragraph').html();
var firstSentence = setval.substring(0, setval.indexOf('.'));
firstSentence = toProperCase(firstSentence);
var theRest = setval.substring(setval.indexOf('.') + 1);
$('#my_paragraph').html(firstSentence + theRest);
关于html - 在 CSS 中将大写锁定更改为大写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22745812/