Search code examples
htmlcsscss-shapeslinear-gradients

Gradient colour with Linear Gradient Border in text using css not working


I would like design £1 similar to the following image using CSS.

£1

I would like to have some text with gradient colour, gradient border and text-shadow in this design. I tried the following code, but it doesn't work.

CSS:

.pound-lbl {
       background-image: linear-gradient(275deg, #f8e71c 0%, #f8bd1c 100%);
       -webkit-background-clip: text;
       color: #FFDE17;
       text-shadow: 0 2px 4px rgba(0,0,0,0.50);
       background: -webkit-linear-gradient(275deg,#F8CC1C 0%, #FFFFFF 100%);
       -webkit-background-clip: text;
       -webkit-text-stroke: 2px transparent;
}

Solution

  • I think the only way to have this effect is to duplicate the text. One will get the stroke coloration and the other the background coloration:

    I used different colors to better identify them:

    span[data-text] {
      display:inline-block;
      font-size:90px;
      font-weight:bold;
      font-family:arial;
      position:relative;
      margin:10px;
    }
    span[data-text]:before {
      content:attr(data-text);
      text-shadow: 0 2px 20px purple;
      background: linear-gradient(to bottom,red 0%, blue 100%);
      -webkit-text-stroke: 5px transparent;    
      -webkit-background-clip: text;
      background-clip: text;
      color:transparent;
    }
    span[data-text]:after {
      content:attr(data-text);
      left:0;
      top:0;
      position:absolute;
      background-image: linear-gradient(275deg, green 0%, yellow 100%);
      -webkit-background-clip: text;
      background-clip: text;
      color: transparent;
    }
    <span data-text="£1"></span>