当前位置:首页 > CSS

css3制作印章文字

2026-02-26 22:28:32CSS

使用CSS3制作印章文字效果

要实现印章文字效果,可以通过CSS3的text-strokeborder-radiustransform等属性模拟印章的圆形边框和文字描边效果。

HTML结构

css3制作印章文字

<div class="seal">
  <span class="seal-text">专用章</span>
</div>

CSS样式

css3制作印章文字

.seal {
  width: 200px;
  height: 200px;
  border: 5px solid #f00;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

.seal-text {
  color: transparent;
  font-size: 36px;
  font-weight: bold;
  -webkit-text-stroke: 2px #f00;
  text-stroke: 2px #f00;
  transform: rotate(-15deg);
}

.seal::before {
  content: "★";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #f00;
  font-size: 24px;
}

添加五角星和环形文字

更复杂的印章效果可以包含五角星和环形排列的文字:

<div class="seal-advanced">
  <div class="star">★</div>
  <div class="circle-text">中华人民共和国</div>
</div>
.seal-advanced {
  width: 300px;
  height: 300px;
  border: 8px solid #f00;
  border-radius: 50%;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

.star {
  color: #f00;
  font-size: 60px;
  position: absolute;
}

.circle-text {
  position: absolute;
  width: 100%;
  height: 100%;
  animation: rotate 15s linear infinite;
}

.circle-text span {
  position: absolute;
  left: 50%;
  font-size: 24px;
  transform-origin: 0 150px;
  color: #f00;
  font-weight: bold;
}

@keyframes rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

使用SVG实现更精确的印章

对于更专业的印章效果,可以使用SVG:

<svg width="300" height="300" viewBox="0 0 300 300">
  <circle cx="150" cy="150" r="140" fill="none" stroke="red" stroke-width="5"/>
  <path id="textPath" d="M50,150a100,100 0 1,1 200,0a100,100 0 1,1 -200,0"/>
  <text fill="red" font-size="24" font-weight="bold">
    <textPath xlink:href="#textPath" startOffset="50%">· 中华人民共和国 ·</textPath>
  </text>
  <text x="150" y="160" text-anchor="middle" fill="red" font-size="60">★</text>
  <text x="150" y="190" text-anchor="middle" fill="red" font-size="30" font-weight="bold">专用章</text>
</svg>

注意事项

  • 文字描边使用text-stroke属性时需注意浏览器兼容性,可能需要添加-webkit-前缀
  • 环形文字布局需要精确计算字符间距和位置
  • 印章颜色通常使用红色(#f00或#c00)
  • 响应式设计时应使用相对单位(如vw/vh)确保印章大小适应不同屏幕

以上方法可根据实际需求组合使用,CSS3方案适合简单印章效果,SVG方案则能实现更复杂精确的印章设计。

标签: 印章文字
分享给朋友:

相关文章

vue 实现轮播文字

vue 实现轮播文字

使用 Swiper 插件实现轮播文字 安装 Swiper 依赖: npm install swiper 在 Vue 组件中引入 Swiper: <template> <d…

vue实现文字扩展

vue实现文字扩展

Vue 实现文字扩展的方法 在 Vue 中实现文字扩展(如展开/收起功能)可以通过动态绑定样式或内容来实现。以下是几种常见的实现方式: 动态绑定 class 或 style 通过 v-bin…

vue实现文字识别

vue实现文字识别

Vue实现文字识别的方案 Vue可以通过集成第三方OCR(光学字符识别)库或API实现文字识别功能。以下是几种常见的实现方式: 使用Tesseract.js库 Tesseract.js是一个纯Ja…

vue实现文字语音播放

vue实现文字语音播放

实现文字语音播放的方法 在Vue中实现文字语音播放,可以通过Web Speech API中的SpeechSynthesis接口完成。以下是具体实现步骤: 安装依赖(可选) 如果需要更多控制或跨浏览器…

vue如何实现文字高亮

vue如何实现文字高亮

实现文字高亮的方法 在Vue中实现文字高亮通常可以通过以下几种方式完成,具体取决于需求场景: 使用v-html指令 通过动态绑定HTML内容,将需要高亮的文字包裹在<span>标签中并…

vue实现文字自动换行

vue实现文字自动换行

实现文字自动换行的基础方法 在Vue中实现文字自动换行可以通过CSS的word-wrap或white-space属性控制。为元素添加以下样式即可实现自动换行: .auto-wrap { word…