Capitalize first letter of sentences CSS

前端 未结 4 1230
面向向阳花
面向向阳花 2020-12-03 06:34

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:



        
4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-03 07:03

    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 that span. Or do it in javascript all together.

    Here's a snippet for the css approach:

    .qcont:first-letter {
      text-transform: capitalize
    }

    word, another word

提交回复
热议问题