【问题标题】:How do i make text with pixelated overlay (html/css)?如何使用像素化叠加 (html/css) 制作文本?
【发布时间】:2022-12-16 08:23:23
【问题描述】:

我有一个 h1 标签,我最初想要一个像素化的叠加层,就像这样

当我结束它时,我希望它淡出过渡以使实际文本可见。

有谁知道我如何用 html 和 css 实现这个?

我试过使用 text-shadow css 属性,但这只会让它变得模糊,而不是像素化。

【问题讨论】:

    标签: html css


    【解决方案1】:

    我不认为 CSS 可以实现文本像素化。我得到的最接近的是这些:

      h1{
        position: relative;
        text-transform: uppercase;
      }
      h1::after{
        position: absolute;
        left: 0;
        bottom: 0;
        content: '';
        width: 480px;
        height: 40px;
        background: url('https://img.freepik.com/free-vector/grey-pixelated-pattern_1053-169.jpg') no-repeat;
        transition: all .2s ease-in;
      }
      h1:hover::after{width: 0;}
    <h1>Never gonna give you up</h1>

    这个有背景剪辑:

    h1{
      font-size: 50px;
      text-transform: uppercase;
      width: max-width;
      background: url('https://img.freepik.com/free-vector/grey-pixelated-pattern_1053-169.jpg');
      background-repeat: no-repeat;
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      }
      h1:hover{
      -webkit-text-fill-color: unset;
      background: none;
      }
    <h1>Never gonna give you up</h1>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-02-04
      • 2018-02-21
      • 1970-01-01
      • 1970-01-01
      • 2011-12-14
      • 2019-11-26
      • 1970-01-01
      相关资源
      最近更新 更多