大写第一句字母CSS [英] Capitalize first letter of sentences CSS
问题描述
我想大写第一个句子的句子,如果可能的话,还要使用逗号后面的第一个字母。我想在这里添加代码:
.qcont {
width:550px ;
height:auto;
float:right;
overflow:hidden;
position:relative;
}
通过使用伪元素:first-letter
来创建 .qcont
元素。
.qcont:first-letter {
pre>
text-transform:capitalize
}
这是最接近你只能使用css。您可以使用javascript(与jQuery组合使用)将每个字母包含在
span
中的句点之后(或逗号,如您所愿)。您可以在span
中添加与上述相同的css。或者在JavaScript中一起做。I want to capitalize the first letter of sentences, and also the first letter after commas if possible. I want to add the code in here:
.qcont { width: 550px; height: auto; float: right; overflow: hidden; position: relative; }
解决方案You can capitalize the first letter of the
.qcont
element by using the pseudo-element:first-letter
..qcont:first-letter{ text-transform: capitalize }
This is the closest you're gonna get using only css. You could use javascript (in combination with jQuery) to wrap each letter which comes after a period (or comma, like you wish) in a
span
. You could add the same css as above to thatspan
. Or do it in javascript all together.这篇关于大写第一句字母CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!