首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何修复SVG文本重叠?

如何修复SVG文本重叠?
EN

Stack Overflow用户
提问于 2020-09-14 14:38:12
回答 1查看 1.5K关注 0票数 0

大家好,我是SVG的新手,我已经搜索了很多次这个问题,但是解决方案不起作用,你怎么能把一些文本放在里面,我的文本元素被我的循环svg重叠了。我也有另一个想法,我将编辑svg,并将一些文字在adobe插画,但我想要一个按钮在其中。

抱歉,我的语法不好

代码语言:javascript
复制
* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}
header {
  height: 100vh;
  width: 100%;
}
.svg-container {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  height: 80%;
  width: 100%;
  flex-direction: column;
  background-color: blue;
}
代码语言:javascript
复制
<div class="svg-container">
   <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1093.75 634.38">
      <defs>
         <style>
            .cls-1,
            .cls-2,
            .cls-3,
            .cls-4 {
            fill: #e6e7e8;
              stroke-miterlimit: 10;
            }
            .cls-1 {
              stroke: #e6e6e6;
              stroke-linecap: round;
            }
            .cls-2 {
              stroke: #ccc;
            }
            .cls-3 {
              stroke: #b3b3b3;
            }
            .cls-4 {
              stroke: #999;
            }
         </style>
      </defs>
      <title>Circles</title>
      <g id="Circle4">
         <text x="100"
               y="50"
               font-family="Verdana"
               font-size="35"
               fill="red">
            Hello
         </text>
         <circle class="cls-1" cx="997.99" cy="538.62" r="90.18" />
      </g>
      <g id="Circle3">
         <circle class="cls-2" cx="806.72" cy="457.71" r="149.49" />
      </g>
      <g id="Circle2">
         <circle class="cls-3"
                 cx="529.65"
                 cy="374.1"
                 r="189.38"
                 transform="translate(-109.39 484.09) rotate(-45)" />
      </g>
      <g id="Circle1">
         <circle class="cls-4" cx="260.7" cy="264.41" r="253.75" />
      </g>
   </svg>
</div>

EN

回答 1

Stack Overflow用户

发布于 2020-09-14 14:42:11

您需要重新排序元素,并将text放在末尾。

代码语言:javascript
复制
* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

header {
  height: 100vh;
  width: 100%;
}

.svg-container {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  height: 80%;
  width: 100%;
  flex-direction: column;
  background-color: blue;
}
代码语言:javascript
复制
<div class="svg-container">
   <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1093.75 634.38">
      <defs>
         <style>
            .cls-1,
            .cls-2,
            .cls-3,
            .cls-4 {
            fill: #e6e7e8;
              stroke-miterlimit: 10;
            }
            .cls-1 {
              stroke: #e6e6e6;
              stroke-linecap: round;
            }
            .cls-2 {
              stroke: #ccc;
            }
            .cls-3 {
              stroke: #b3b3b3;
            }
            .cls-4 {
              stroke: #999;
            }
         </style>
      </defs>
      <title>Circles</title>
      <g id="Circle4">
         <circle class="cls-1" cx="997.99" cy="538.62" r="90.18" />
      </g>
      <g id="Circle3">
         <circle class="cls-2" cx="806.72" cy="457.71" r="149.49" />
      </g>
      <g id="Circle2">
         <circle class="cls-3"
                 cx="529.65"
                 cy="374.1"
                 r="189.38"
                 transform="translate(-109.39 484.09) rotate(-45)" />
      </g>
      <g id="Circle1">
         <circle class="cls-4" cx="260.7" cy="264.41" r="253.75" />
      </g>
      <text x="100"
            y="50"
            font-family="Verdana"
            font-size="35"
            fill="red">
         Hello
      </text>
   </svg>
</div>

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63886496

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档