且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

CSS文本转换大写的所有大写

更新时间:2023-11-21 18:19:52

没有办法使用CSS,你可以使用PHP或Javascript。

There is no way to do this with CSS, you could use PHP or Javascript for this.

PHP示例:

$text = "ALL CAPS";
$text = ucwords(strtolower($text)); // All Caps

jQuery示例(现在是一个插件):

jQuery example (it's a plugin now!):

// Uppercase every first letter of a word
jQuery.fn.ucwords = function() {
  return this.each(function(){
    var val = $(this).text(), newVal = '';
    val = val.split(' ');

    for(var c=0; c < val.length; c++) {
      newVal += val[c].substring(0,1).toUpperCase() + val[c].substring(1,val[c].length) + (c+1==val.length ? '' : ' ');
    }
    $(this).text(newVal);
  });
}

$('a.link').ucwords();​