【问题标题】:Gradient text with backgroud-clip: text property breaking up on Mac Safari带有背景剪辑的渐变文本:Mac Safari 上的文本属性分解
【发布时间】:2019-02-04 10:27:04
【问题描述】:

带有 background-clip 属性的渐变文本在 Mac Safari 中被弄乱了,就像 http://prntscr.com/mgd5tz。这是我的跨度渐变文本代码

.text-grad {
	background: -moz-linear-gradient(150deg, #97c74e 0%, #2ab9a5 100%);
	background: -webkit-gradient(linear, left top, right top, color-stop(0%, #97c74e), color-stop(100%, #2ab9a5));
	background: -webkit-linear-gradient(150deg, #97c74e 0%, #2ab9a5 100%);
	background: -o-linear-gradient(150deg, #97c74e 0%, #2ab9a5 100%);
	background: -ms-linear-gradient(150deg, #97c74e 0%, #2ab9a5 100%);
	background: linear-gradient(150deg, #97c74e 0%, #2ab9a5 100%);
	filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='$color-one', endColorstr='$color-two',GradientType=1 );
	-webkit-background-clip: text;
	-moz-background-clip: text;
	-ms-background-clip: text;
	-o-background-clip: text;
	background-clip: text;
	-webkit-text-fill-color: transparent;
	-moz-text-fill-color: transparent;
	-ms-text-fill-color: transparent;
	-o-text-fill-color: transparent;
	text-fill-color: transparent;
	opacity: 1;
	z-index: 9;
}
<h2>Lorem ipsum <span class="text-grad"> deep understanding </span> of the project</h2>

【问题讨论】:

  • 它对我来说很好用。我在 Safari 中检查过

标签: css macos safari cross-browser word-break


【解决方案1】:

添加显示:inline-block;可能会工作

.text-grad {
  display: inline-block;
	background: -moz-linear-gradient(150deg, #97c74e 0%, #2ab9a5 100%);
	background: -webkit-gradient(linear, left top, right top, color-stop(0%, #97c74e), color-stop(100%, #2ab9a5));
	background: -webkit-linear-gradient(150deg, #97c74e 0%, #2ab9a5 100%);
	background: -o-linear-gradient(150deg, #97c74e 0%, #2ab9a5 100%);
	background: -ms-linear-gradient(150deg, #97c74e 0%, #2ab9a5 100%);
	background: linear-gradient(150deg, #97c74e 0%, #2ab9a5 100%);
	filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='$color-one', endColorstr='$color-two',GradientType=1 );
	-webkit-background-clip: text;
	-moz-background-clip: text;
	-ms-background-clip: text;
	-o-background-clip: text;
	background-clip: text;
	-webkit-text-fill-color: transparent;
	-moz-text-fill-color: transparent;
	-ms-text-fill-color: transparent;
	-o-text-fill-color: transparent;
	text-fill-color: transparent;
	opacity: 1;
	z-index: 9;
}
   <h2>Lorem ipsum <span class="text-grad"> deep</span> <span class="text-grad">understanding </span> of the project</h2>

【讨论】:

  • 显示:inline-block 工作正常,但它破坏了段落中的文本 像这样prnt.sc/mgrazb 任何帮助都非常感谢感谢您的帮助!
  • 我更改了代码,现在它可以正常工作了,如果您将需要获得渐变的每个单词放在不同的跨度中,它就会起作用:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-10-11
  • 1970-01-01
  • 2020-07-01
  • 1970-01-01
  • 2022-11-12
  • 2020-08-13
相关资源
最近更新 更多