在css中使第一个字符大写 [英] make the first character uppercase in css

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

问题描述

是有一种方法使第一个字符大写在css中的标签。
html结构是

is there a way to make the first character uppercase in the a label in css. the html structure is

<a class="m_title" href="">gorr</a>
<a class="m_title" href="">trro</a>
<a class="m_title" href="">krro</a>
<a class="m_title" href="">yrro</a>
<a class="m_title" href="">gwwr</a>


推荐答案

a.m_title {
    text-transform: capitalize;
}

如果您的链接可以包含多个单词,第一个字要大写,使用:第一个字母使用不同的变换(虽然它并不重要)。注意,为了:first-letter 起作用,您的元素需要显示为块:

If your links can contain multiple words and you only want the first letter of the first word to be uppercase, use :first-letter with a different transform instead (although it doesn't really matter). Note that in order for :first-letter to work your a elements need to display as blocks:

a.m_title {
    display: block;
}

a.m_title:first-letter {
    text-transform: uppercase;
}

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

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