我使用inkscape将一些文本放在矩形内,因此树就像
<svg:rect><svg:text><svg:tspan>text....
问题是,我看不到文字。我试图摆弄矩形的不透明度无济于事。应该有一种方法可以从UI中执行此操作吗?
修改
按要求提供的示例
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="184.25197"
height="262.20471"
id="svg2"
sodipodi:version="0.32"
inkscape:version="0.46"
version="1.0"
sodipodi:docname="ex1.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape">
<defs
id="defs4">
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 526.18109 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="744.09448 : 526.18109 : 1"
inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
id="perspective10" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
gridtolerance="10000"
guidetolerance="10"
objecttolerance="10"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.64"
inkscape:cx="195.9221"
inkscape:cy="335.3072"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="640"
inkscape:window-height="675"
inkscape:window-x="44"
inkscape:window-y="44" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<rect
style="opacity:0.25480766;fill:#ff0000;fill-opacity:1;stroke:#000000;stroke-width:12.94795799;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect2383"
width="150.87796"
height="84.226181"
x="18.221733"
y="39.557121">
<text
xml:space="preserve"
style="font-size:56.0331955px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
x="44.815186"
y="114.0088"
id="text2385"
transform="scale(1.0054479,0.9945816)"><tspan
sodipodi:role="line"
id="tspan2387"
x="44.815186"
y="114.0088">text</tspan></text>
</rect>
</g>
</svg>
我希望能够在inkscape中看到这一点。
解决方法是将文本放在框上方的图层上(意图是框遮盖了它下面的图层),而不是尝试使用嵌套标记变得聪明。可惜它不起作用。
答案 0 :(得分:12)
rect元素不能包含根据svg规范无效的文本元素,并且只会被兼容的用户代理忽略。
将文本放在rect元素后面,让它们呈现在顶部。