CSS实现英文或拼音单词首字母大写,只需要在css样式中加入:
text-transform: capitalize
即可。
测试代码如下:
<!doctype html><html><head><meta charset="utf-8"><title>英文或拼音单词首字母大写</title><style>.shou_daxie {text-transform: capitalize}.quan_daxie {text-transform: uppercase}.quan_xiaoxie {text-transform: lowercase}</style></head><body><div class="shou_daxie"> 首字母大写: the bus will depart at the scheduled time regardless of latecomers</div><div class="quan_daxie"> 字母全实现大写: tHe Bus wIll dePart at the scHeduled Time rEgardless of latecomers</div><div class="quan_xiaoxie"> 字母全实现小写: tHe Bus wIll dePart at the scHeduled Time rEgardless of latecomers</div></body></html>
结果如下:
首字母大写: The Bus Will Depart At The Scheduled Time Regardless Of Latecomers字母全实现大写: THE BUS WILL DEPART AT THE SCHEDULED TIME REGARDLESS OF LATECOMERS字母全实现小写: the bus will depart at the scheduled time regardless of latecomers