【发布时间】:2018-06-11 03:51:33
【问题描述】:
我找到了一个 jsfiddle,它可以将颜色渐变应用于特定的文本行。它为每行文本应用不同的 2 色渐变。它有一个一致的模式。黑到红,红到黑,黑到蓝,蓝到黑。
我不知道它是如何工作的。谁能解释一下?
这里是 jsfiddle
https://jsfiddle.net/cers/o9s70yjq/2/
这里是代码
HTML
<p><em>Nobody is perfect.</em> At times we have difficulty managing our finances, we don’t always take our medications as planned, and sometimes we don’t perform up to par at work. However, research shows that people experience these problems to different degrees. Across financial strata, research reveals that the financially less well-off engage in these behaviors more often than those who are financially stable (1). These behaviors are particularly concerning, because, for those with limited financial resources, they can lead to poverty as well as perpetuate it.</p>
<p>In their article, “<a href="http://www.sciencemag.org/content/341/6149/976">Poverty Impedes Cognitive Function</a>,” which appears in the latest issue of Science, University of Warwick Professor Anandi Mani and several other social scientists (2) suggest poverty, and the ever-present concerns that come with it, places an undue burden on an individual’s limited mental resources. Compared with those who are free from poverty, this burden leaves those in poverty with fewer cognitive resources with which to make choices and take action. Mani et al. write, the poor “are less capable not because of inherent traits, but because the very context of poverty imposes load and impedes cognitive capacity.”</p>
<p>However, it is important to note that their explanation is not limited to the traditional populations of poverty, defined by a specific income level or ability to access basic human needs. The authors define poverty “broadly as the gap between one’s needs and the resources available to fulfill them.” That is, people in poverty are those who feel “poor,” who feel they have less than they need.</p>
这里是 CSS
p {
margin: 0 0 1.5em 0;
line-height: 1.5em;
padding: 0;
background: url(data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%02%00%00%00%3C%08%02%00%00%00%C3%A4%FC%AE%00%00%00%25IDAT%18%D3c```%F8%CF%C0%C0%C4%C0%C0%C0%40S%8A%E1%3F%ADm%80Y%04%B1%8D.%16%FD%A7%8B%8F%00e%B4%04m%18%DC%1D%8A%00%00%00%00IEND%AEB`%82) 0 0 / 100% 6em repeat-y;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
em {
font-weight: bolder;
font-style: normal;
}
a {
text-decoration-color: black;
}
【问题讨论】:
-
背景剪辑。他们为背景分配颜色,然后将其用作
background-clip的文本颜色 -
我仍然想知道背景是如何与每一行文本自动对齐的。
-
谢谢!还有一件事,“0 0 / 100% 6em repeat-y;”是什么意思?在代码中做什么?
-
@PatrickJFitzgerald 我已经在下面的回答中将其解释为评论
标签: css