美文网首页
CSS 文本描边效果

CSS 文本描边效果

作者: hvkcoder | 来源:发表于2018-07-26 23:16 被阅读17次

text-shadow 实现文本描边

h1{
    text-shadow:
        -.025em -.025em 0 #444,
        .025em -.025em 0 #444,
        -.025em  .025em 0 #444,
        .025em  .025em 0 #444;
}

text-stroke 实现文本描边

  • text-stroke 是 ext-stroke-width 和 text-stroke-color 的两个属性简写写法
text-stroke:<width> <color>
  • text-stroke 属性常常与 text-fill-color (文本填充颜色) 一起使用
h1{
    -webkit-text-fill-color:transparent;
    -webkit-text-stroke:6px #f36;
}

实现渐变文本描边

h1{
    background:-linear-gradient(-86deg, #EEF85B 5%, #7AEC8D 53%, #09E5C3 91%);
    -webkit-background-clip:text;
    -webkit-text-fill-color:#fff;
    -webkit-text-stroke:6px transparent;
}

使用 SVG 实现描边

<svg width="100%" height="300">
    <text class="text" x="100" y="150">H_VK</text>
</svg>

.text{
    fill:transparent;
    stroke-width:90px;
    stroke:#096;
}

SVG 动画描边

<svg viewBox="0 0 1320 300">
    <symbol id="s-text">
        <text text-anchor="middle"  x="50%" y="50%" dy=".35em">
            H_VK
        </text>
    </symbol>
    <use xlink:href="#s-text" class="text"></use>
        <use xlink:href="#s-text" class="text"></use>
        <use xlink:href="#s-text" class="text"></use>
        <use xlink:href="#s-text" class="text"></use>
        <use xlink:href="#s-text" class="text"></use>
</svg>
.text {
    fill: none;
    stroke-width: 6;
    stroke-linejoin: round;
    stroke-dasharray: 70 330;
    stroke-dashoffset: 0;
    animation: stroke 6s infinite linear;
}

.text:nth-child(5n + 1) {
    stroke: #F2385A;
    animation-delay: -1.2s;
}
.text:nth-child(5n + 2) {
    stroke: #F5A503;
    animation-delay: -2.4s;
}

.text:nth-child(5n + 3) {
    stroke: #E9F1DF;
    animation-delay: -3.6s;
}

.text:nth-child(5n + 4) {
    stroke: #56D9CD;
    animation-delay: -4.8s;
}

.text:nth-child(5n + 5) {
    stroke: #3AA1BF;
    animation-delay: -6s;
}

@keyframes stroke {
    100% {
        stroke-dashoffset: -400;
    }
}

/* Other styles */
html, body {
    height: 100%;
}

body {
    background: #212121;
    background-size: .2em 100%;
    font: 14.5em/1 Open Sans, Impact;
    text-transform: uppercase;
    margin: 0;
}

svg {
    position: absolute;
    width: 100%;
    height: 100%;
}

实现 Canvas 实现描边

<canvas id="canvas"></canvas>
var canvas = document.getElementById("canvas"),
context = canvas.getContext("2d");
canvas.width = canvas.height = 800;
context.lineWidth = 6;
context.font = '8em/1 Bangers, sans-serif';
context.strokeStyle = '#f36';
context.strokeText("Hello H_VK",0, canvas.height / 2);

文章 GitHub 地址 :https://github.com/SilenceHVK/blog/issues/32 ,欢迎 Star。

相关文章

  • CSS 文本描边效果

    text-shadow 实现文本描边 text-stroke 实现文本描边 text-stroke 是 ext-s...

  • ios 文字外描边效果

    设计提出文字描边效果,但是富文本自带的文字描边效果,是向文字内外同时描边 效果 所以需要自己实现,采用的方法是重写...

  • 使用CSS给文字添加描边效果

    CSS如何实现文字描边效果?下面本篇文章就来给大家介绍一下使用CSS给文字添加描边效果的方法,希望对大家有所帮助。...

  • HTML5 Canvas笔记——交互绘制文本(描边、填充、阴影、

    (1)文本的描边、填充、阴影(2)文本的渐变填充(3)文本的图案填充(4)文本的属性设置及效果呈现 交互绘制文本....

  • 通过富文本描边功能实现字体加粗效果

    通过富文本描边功能实现字体加粗效果 如果NSStrokeWidthAttributeName设置一个正值,则实现的...

  • 文字描边效果

    简单描边 渐变描边 主要是用到背景渐变的样式。 SVG多彩描边效果 SVG动画霓虹灯效果

  • box-shadow 效果大全

    box-shadow 效果大全(内阴影,外阴影,三边阴影,双边阴影,单边阴影,细线描边…)CSS3 box-sha...

  • ios开发文字内描边效果

    实现了外描边效果之后,产品问内描边好做吗,我说简单!简单个蛋! 因为苹果本身的描边效果,是双向描边,不是单侧的,见...

  • CSS文字描边

    直接上代码css代码:div { margin: 50px auto 100px; font-size: 100p...

  • PPT文字描边效果大比拼

    看到文章标题你一定很纳闷,PPT文字描边效果有什么好说的,很简单啊,输入文字,点击右键,设置形状格式,选择文本效果...

网友评论

      本文标题:CSS 文本描边效果

      本文链接:https://www.haomeiwen.com/subject/quiimftx.html