Add stroke around text - on the outside - with css?

后端 未结 9 1494
走了就别回头了
走了就别回头了 2021-01-03 21:48

I have the following HTML and CSS:

9条回答
  •  滥情空心
    2021-01-03 22:19

    The -webkit-text-stroke doesn't support placing the stroke on the outside of the text

    as this CSS-Tricks atricle explains:

    The stroke drawn by text-stroke is aligned to the center of the text shape (as is the default in Adobe Illustrator), and there is currently no option to set the alignment to the inside or outside of the shape. Unfortunately this makes it much less usable, as no matter what now the stroke interferes with the shape of the letter destroying the original type designers intent. A setting would be ideal, but if we had to pick one, outside stroke would have been much more useful.

    What about SVG?

    Well it seems that it also places the stroke on the inside -

    FIDDLE

    However,

    you might be able to simulate this effect (depending on what you need) by:

    1) Change your font to a sans serif like verdana and

    2) Make the font-size of text you are adding a stroke to slightly larger

    body {
      background: grey;
      font-family: verdana;
    }
    .stroke,
    .no-stroke {
      color: white;
      font-size: 2.5em;
    }
    .stroke {
      -webkit-text-stroke: 2px black;
       font-size: 2.7em;
    }

    WHAT CARRER SHOULD YOU HAVE ?

    WHAT CARRER SHOULD YOU HAVE ?

提交回复
热议问题