xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

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

  1. 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/

  1. 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

(🐞 反爬虫测试!打击盗版⚠️)如果你看到这个信息, 说明这是一篇剽窃的文章,请访问 https://www.cnblogs.com/xgqfrms/ 查看原创文章!



©xgqfrms 2012-2021

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2021-11-21 23:20  xgqfrms  阅读(41)  评论(4编辑  收藏  举报