Using CSS, how do you create a text stroke outline that is *thicker* than 1px?

假装没事ソ 提交于 2019-12-22 08:40:09

问题


Below is the code I was using to do a Text Stroke outline of 1px. But how do I get the outline thicker? If I just replace all "1px" with "5px", the result looks crazy.

HTML

<div class="element">
Hello!
</div>

CSS

.element {
color:white;

    text-shadow:
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000,
        1px 1px 0 #000;
}

回答1:


You might use SVG as well, though it requires more code:

.element {
  font-size: 50px;
}

svg {
  width: 100%;
  height: 1.3em;
}

svg text {
  fill: pink;
  stroke-width: 8px;
  paint-order: stroke;
  stroke: violet;
}
<div class="element">
  <svg><text x="8px" y="75%">Hello kitty!</text></svg>
</div>



回答2:


You can consider text-stroke but you need to pay attention to browser support

.element {
  color: white;
  font-size:50px;
  -webkit-text-stroke: 5px #000;
}
<div class="element">
  Hello!
</div>


来源:https://stackoverflow.com/questions/51459653/using-css-how-do-you-create-a-text-stroke-outline-that-is-thicker-than-1px

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!