CSS text-transform All In One
CSS text-transform All In One
CSS 实现字母大小写
uppercase / 字母全部大写
lowercase / 字母全部小写
capitalize / 仅首字母大写
/* Keyword values */
text-transform: capitalize;
text-transform: uppercase;
text-transform: lowercase;
text-transform: none;
text-transform: full-width;
/* Global values */
text-transform: inherit;
text-transform: initial;
text-transform: unset;
demos
- CSS 实现
首字母
大写 (🚀 ✅ 简洁优雅,一行样式搞定)
text-transform
.test {
text-transform: capitalize;
}
https://developer.mozilla.org/en-US/docs/Web/CSS/text-transform
https://css-tricks.com/almanac/properties/t/text-transform/
- JS 实现
首字母
大写 (💩 👎复杂冗长,需要好几行代码实现)
const test = document.querySelector(`.test`)
const str = test.innerText;
const [first, ...rest] = str;
test.innerText = `${first}`.toUpperCase() + rest.join(``);
`test`.slice(0, 1).toUpperCase() + `test`.slice(1);
// 'Test'
CSS font 渐变色
/*
影响因素,
font-family
font-weight
font-size
width
height
字间距,行高等等属性
*/
https://codepen.io/xgqfrms/pen/ExvJmqp
// $font: 'Poppins', sans-serif;
$font: sans-serif;
// ::selection { background-color: #C3CFE2; }
body {
width: 100%;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
// background: linear-gradient(to right, #FDFBFB, #EBEDEE 70%);
}
.text {
text-transform: uppercase;
// background: linear-gradient(to right, #30CFD0 0%, #330867 100%);
// background: linear-gradient(135deg, #fe9eff, #99fffc 33%, #eaffa7 66%);
background: linear-gradient(to right bottom, #fe9eff, #99fffc 50%, #eaffa7 70%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
font: {
size: 20vw;
family: $font;
font-weight: 800;
};
}
CSS 字体渐变色,关键字段 clip,transparent,multi background-image
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
color: transparent;
background
background-image
refs
CSS 字体渐变色
https://www.cnblogs.com/xgqfrms/p/12913451.html
https://www.cnblogs.com/xgqfrms/p/13560134.html
©xgqfrms 2012-2021
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/15586539.html
未经授权禁止转载,违者必究!
标签:
CSS
, text-transform
, Uppercase
, lowercase
, toUpperCase
, 首字母大写
, 字母大小写
, capitalize
, toLowerCase
, JavaScript
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
2020-11-21 Battery API All In One
2020-11-21 如何使用 js 的 Promise 实现 Fetch 请求超时自动重试 All In One
2019-11-21 HTML5 Server-Sent Events
2019-11-21 Learning React in depth with React Official Documents
2019-11-21 js in depth & prototype & __proto__
2018-11-21 Access-Control-Allow-Methods: OPTIONS & CORS All In One
2015-11-21 IcoMoon 图标字体 Custom built and crisp icon fonts, done right