text-stroke详解

text-stroke详解
属性定义及使用说明

text-stroke 属性是用来为文本添加描边效果的CSS属性,但请注意,它并非标准CSS属性,而是WebKit(如Safari和Chrome)浏览器专有的CSS扩展属性。为了兼容其他浏览器,通常会配合 -webkit-text-stroke 和 -moz-text-stroke 等私有前缀属性一起使用。

语法
-webkit-text-stroke: stroke-width color;
-moz-text-stroke: stroke-width color;

需要注意的是,使用-webkit-text-stroke会导致文本的渲染性能下降,特别是当文本内容非常多或者在移动设备上时,可能会影响到性能和体验。

属性描述
stroke-width规定文本描边的宽度,可以用长度单位(如 px、em 等)指定。
color描边的颜色,可以是任何有效的CSS颜色值,比如 red、#FF0000 或 rgba(255, 0, 0, 0.5)。
属性详解
  • stroke-width
    规定文本描边的宽度,可以用长度单位(如 px、em 等)指定。

    <div class="container container1">1像素宽的红色描边</div>
    <div class="container container2">0.06em的红色描边</div>
    
    .container1 {
        -webkit-text-stroke: 1px red;
    }
    .container2 {
        -webkit-text-stroke: 0.06em red;
    }
    

    效果如下:
    在这里插入图片描述

  • color
    描边的颜色。可以是任何有效的CSS颜色值,比如 red、#FF0000 或 rgba(255, 0, 0, 0.5)。

    .container1 {
        -webkit-text-stroke: 1px red;
    }
    .container2 {
        -webkit-text-stroke: 1px green;
    }
    

    在这里插入图片描述

镂空示例:
在这里插入图片描述
代码如下:

.container {
    font-size: 36px;
    color: transparent;
}
.container1 {
    -webkit-text-stroke: 1px red;
}
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 500" width="800" height="500"> <!-- 背景 --> <rect width="800" height="500" fill="#f9f9f9"/> <!-- 标题 --> <text x="400" y="30" font-family="Arial" font-size="24" text-anchor="middle" font-weight="bold">CSDA模块架构图</text> <!-- 主模块框 --> <rect x="100" y="80" width="600" height="380" rx="10" ry="10" fill="white" stroke="#333" stroke-width="2"/> <text x="400" y="110" font-family="Arial" font-size="18" text-anchor="middle" font-weight="bold">CSDA (Cross-Scale Dual Attention) 模块</text> <!-- 输入特征 --> <rect x="150" y="150" width="120" height="60" rx="5" ry="5" fill="#e6f7ff" stroke="#1890ff" stroke-width="2"/> <text x="210" y="185" font-family="Arial" font-size="14" text-anchor="middle">多尺度特征</text> <text x="210" y="205" font-family="Arial" font-size="12" text-anchor="middle">P3, P4, P5, P6, P7</text> <!-- 空间注意力分支 --> <rect x="320" y="150" width="120" height="60" rx="5" ry="5" fill="#fff2e8" stroke="#fa8c16" stroke-width="2"/> <text x="380" y="185" font-family="Arial" font-size="14" text-anchor="middle">空间注意力</text> <text x="380" y="205" font-family="Arial" font-size="12" text-anchor="middle">分支</text> <!-- 通道注意力分支 --> <rect x="500" y="150" width="120" height="60" rx="5" ry="5" fill="#f6ffed" stroke="#52c41a" stroke-width="2"/> <text x="560" y="185" font-family="Arial" font-size="14" text-anchor="middle">通道注意力</text> <text x="560" y="205" font-family="Arial" font-size="12" text-anchor="middle">分支</text> <!-- 特征交互 --> <rect x="380" y="250" width="120" height="60" rx="5" ry="5" fill="#f0f0f0" stroke="#1890ff" stroke-width="2"/> <text x="440" y="285" font-family="Arial" font-size="14" text-anchor="middle">特征交互</text> <text x="440" y="305" font-family="Arial" font-size="12" text-anchor="middle">与融合</text> <!-- 输出特征 --> <rect x="320" y="350" width="120" height="60" rx="5" ry="5" fill="#e6f7ff" stroke="#1890ff" stroke-width="2"/> <text x="380" y="385" font-family="Arial" font-size="14" text-anchor="middle">增强特征</text> <text x="380" y="405" font-family="Arial" font-size="12" text-anchor="middle">P3&#39;, P4&#39;, P5&#39;, P6&#39;, P7&#39;</text> <!-- 空间注意力内部结构 --> <rect x="280" y="120" width="200" height="180" rx="5" ry="5" fill="none" stroke="#fa8c16" stroke-width="1.5" stroke-dasharray="5,3"/> <text x="380" y="135" font-family="Arial" font-size="12" text-anchor="middle" fill="#fa8c16">空间注意力分支内部结构</text> <!-- 空间注意力-特征提取 --> <rect x="300" y="130" width="160" height="40" rx="5" ry="5" fill="#fff7e6" stroke="#fa8c16" stroke-width="1"/> <text x="380" y="155" font-family="Arial" font-size="12" text-anchor="middle">多尺度特征提取</text> <!-- 空间注意力-聚合 --> <rect x="300" y="180" width="160" height="40" rx="5" ry="5" fill="#fff7e6" stroke="#fa8c16" stroke-width="1"/> <text x="380" y="205" font-family="Arial" font-size="12" text-anchor="middle">跨尺度特征聚合</text> <!-- 空间注意力-生成 --> <rect x="300" y="230" width="160" height="40" rx="5" ry="5" fill="#fff7e6" stroke="#fa8c16" stroke-width="1"/> <text x="380" y="255" font-family="Arial" font-size="12" text-anchor="middle">空间注意力生成</text> <!-- 通道注意力内部结构 --> <rect x="480" y="120" width="200" height="180" rx="5" ry="5" fill="none" stroke="#52c41a" stroke-width="1.5" stroke-dasharray="5,3"/> <text x="580" y="135" font-family="Arial" font-size="12" text-anchor="middle" fill="#52c41a">通道注意力分支内部结构</text> <!-- 通道注意力-全局池化 --> <rect x="500" y="130" width="160" height="40" rx="5" ry="5" fill="#f6ffed" stroke="#52c41a" stroke-width="1"/> <text x="580" y="155" font-family="Arial" font-size="12" text-anchor="middle">全局上下文建模</text> <!-- 通道注意力-特征映射 --> <rect x="500" y="180" width="160" height="40" rx="5" ry="5" fill="#f6ffed" stroke="#52c41a" stroke-width="1"/> <text x="580" y="205" font-family="Arial" font-size="12" text-anchor="middle">跨尺度特征映射</text> <!-- 通道注意力-生成 --> <rect x="500" y="230" width="160" height="40" rx="5" ry="5" fill="#f6ffed" stroke="#52c41a" stroke-width="1"/> <text x="580" y="255" font-family="Arial" font-size="12" text-anchor="middle">通道注意力生成</text> <!-- 连接箭头 --> <!-- 输入到空间注意力 --> <line x1="270" y1="180" x2="320" y2="180" stroke="#333" stroke-width="2" marker-end="url(#arrowhead)"/> <!-- 输入到通道注意力 --> <line x1="440" y1="180" x2="500" y2="180" stroke="#333" stroke-width="2" marker-end="url(#arrowhead)"/> <!-- 空间注意力到特征交互 --> <line x1="380" y1="210" x2="380" y2="250" stroke="#333" stroke-width="2" marker-end="url(#arrowhead)"/> <!-- 通道注意力到特征交互 --> <line x1="560" y1="210" x2="560" y2="275" x3="440" y3="275" stroke="#333" stroke-width="2" marker-end="url(#arrowhead)"/> <!-- 特征交互到输出 --> <line x1="440" y1="310" x2="440" y2="350" stroke="#333" stroke-width="2" marker-end="url(#arrowhead)"/> <!-- 输入输出标签 --> <text x="100" y="180" font-family="Arial" font-size="14" text-anchor="end">输入</text> <text x="100" y="410" font-family="Arial" font-size="14" text-anchor="end">输出</text> <!-- 箭头标记定义 --> <defs> <marker id="arrowhead" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto"> <polygon points="0 0, 10 3.5, 0 7" fill="#333"/> </marker> </defs> <!-- 图例 --> <rect x="600" y="420" width="20" height="20" fill="#e6f7ff" stroke="#1890ff" stroke-width="2"/> <text x="630" y="435" font-family="Arial" font-size="12">特征数据</text> <rect x="600" y="450" width="20" height="20" fill="#fff2e8" stroke="#fa8c16" stroke-width="2"/> <text x="630" y="465" font-family="Arial" font-size="12">空间注意力</text> <rect x="600" y="480" width="20" height="20" fill="#f6ffed" stroke="#52c41a" stroke-width="2"/> <text x="630" y="495" font-family="Arial" font-size="12">通道注意力</text> </svg>
最新发布
05-21
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值