怎么使用纯CSS实现锡纸撕开的文字效果

发布时间:2022-02-28 14:17:23 作者:小新
来源:亿速云 阅读:164

小编给大家分享一下怎么使用纯CSS实现锡纸撕开的文字效果,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!

  代码解读

  定义dom,容器中包含若干子元素,每个子元素中包含一个字母:

  <divclass="text">

  <span>A</span>

  <span>W</span>

  <span>E</span>

  <span>S</span>

  <span>O</span>

  <span>M</span>

  <span>E</span>

  </div>

  定义容器尺寸:

  body{

  margin:0;

  height:100vh;

  }

  .text{

  width:100%;

  height:100%;

  }

  设置子元素的布局方式:

  .text{

  display:flex;

  justify-content:space-between;

  }

  .textspan{

  width:100%;

  }

  定义文本样式:

  .textspan{

  color:darkslategray;

  background-color:rgb(127,140,141);

  font-family:serif;

  font-size:12vmin;

  text-shadow:1px1px1pxwhite;

  display:flex;

  align-items:center;

  justify-content:center;

  }

  设置文本的背景的渐变色,奇数位的文字和偶数位的文字的渐变方向是相反的:

  .textspan:nth-child(odd){

  background:linear-gradient(

  tobottom,

  rgba(127,140,141,0.2)0%,

  rgba(127,140,141,0)33%,

  rgba(127,140,141,0.7)66%,

  rgba(127,140,141,0.2)100%

  );

  }

  .textspan:nth-child(even){

  background:linear-gradient(

  totop,

  rgba(127,140,141,0.2)0%,

  rgba(127,140,141,0)33%,

  rgba(127,140,141,0.7)66%,

  rgba(127,140,141,0.2)100%

  );

  }

  增加文字之间的分隔线,第1个文字之前不用加分隔线:

  .textspan{

  position:relative;

  }

  .textspan:not(:first-child)::before{

  content:'';

  position:absolute;

  width:10px;

  height:90%;

  background-color:black;

  left:-5px;

  border-left:1pxsolidwhite;

  border-radius:50%;

  }

  让分隔线上下错位:

  .textspan:not(:first-child):nth-child(odd)::before{

  top:2%;

  }

  .textspan:not(:first-child):nth-child(even)::before{

  bottom:2%;

  }

以上是“怎么使用纯CSS实现锡纸撕开的文字效果”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!

推荐阅读:
  1. css中怎么实现文字效果
  2. 如何利用纯CSS实现动态的文字效果

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

css

上一篇:CSS如何实现小球抛物线运动的动画效果

下一篇:怎么用纯CSS实现小球跳跃台阶的动画效果

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》