大写第一句字母CSS [英] Capitalize first letter of sentences CSS

查看:131
本文介绍了大写第一句字母CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想大写第一个句子的句子,如果可能的话,还要使用逗号后面的第一个字母。我想在这里添加代码:

  .qcont {
width:550px ;
height:auto;
float:right;
overflow:hidden;
position:relative;
}


解决方案

通过使用伪元素:first-letter 来创建 .qcont 元素。

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

这是最接近你只能使用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 that span. Or do it in javascript all together.

这篇关于大写第一句字母CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆