2013-05-10 60 views
3

我正在尝试使用内嵌样式标记来设置我的45个多边形和5个矩形。 出于某种原因,我尝试风格的第一个标签不会选择造型。如果我在顶部添加第三个形状,那么它下面的两个形状将被设置为样式,如果我删除了顶部的第三个形状,那么它下面的第二个形状将不会被设置样式。这之前是否发生过这种情况?你如何使用css来设计svg标签?

<style type="text/css"><![CDATA[ 
     <!--this rectangle will not be styled --> 
     rect{ 
     fill:none; 
     stroke:black; 
     stroke-width:.5; 
     } 
     polygon{ 
     fill:none; 
     stroke:black; 
     stroke-width:.5; 
     } 



]]></style> 

现在使用下面的代码,矩形得到样式。 (在顶部的第二多边形标签)

<style type="text/css"><![CDATA[ 

    polygon{ 
    fill:none; 
    stroke:black; 
    stroke-width:.5; 
    } 
    rect{ 
    fill:none; 
    stroke:black; 
    stroke-width:.5; 
    } 
    polygon{ 
    fill:none; 
    stroke:black; 
    stroke-width:.5; 
    } 
]]></style> 
<svg width="400" height="800" viewBox="0 0 400 800" id="svg-doc"> 
<rect id="central-park" class="shape" x="154" y="370"width="53" height="127" /> 
      <rect id="shape-z10024" class="shape" x="68" y="415" width="85" height="40" /> 
      <rect id="shape-z10023" class="shape" x="68" y="457" width="85" height="40" /> 
      <polygon id="shape-z10034" class="shape" points="189,156 137,122 106,121 101,129 99,155 79,155 78,105 94,79 121,67 128,82 163,61 177,62 191,80" /> 
      <a xlink:href="http://google.com/"> 
      <polygon id="shape-z10040" class="shape" points="188,167 186,155 137,122 108,122 102,126 100,153 77,156 77,166" /> 
      </a> 
      <polygon id="shape-z10033" class="shape" points="189,166 187,197 187,203 81,203 77,194 78,166" /> 
      <polygon id="shape-z10032" class="shape" points="189,205 160,234 155,248 84,247 80,204" /> 
      <polygon id="shape-z10030" class="shape" points="268,311 196,315 197,299 157,298 157,273 234,273" /> 
</svg> 
+2

你能建立一个[的jsfiddle(HTTP: //jsfiddle.net/)呢? – miah 2013-05-10 19:56:36

+0

为什么你在'