简体   繁体   English

可见性不适用于svg g标签

[英]visibility is not working for svg g tag

I'm using svg in my application and i using g tag to group the all elements. 我在我的应用程序中使用svg,我使用g标签将所有元素分组。 The first g tag contain more than g tag's, all g tag have their own different visibility style. 第一个g标签包含多个g标签,所有g标签都有各自不同的可见性样式。 If i set visibility hidden to the parent g tag it will affect the other g tag elements. 如果我将可见性设置为对父g标签隐藏,则会影响其他g标签元素。 I need to hide all the g tag elements by setting visibility to the parent but child elements visibility style should not change. 我需要通过将可见性设置为父项来隐藏所有g标签元素,但子元素的可见性样式不应更改。

Here the sample svg 这里是样本svg

<svg height: "200" width="200">
    <g style="visibility:hidden">
        <g style="visibility:visible">
            <circle cx="100" cy="100" fill="green" r="15" />
        </g>
    </g>
</svg>

Here is the working Sample. 这是工作示例。
How can set visibility to the parent g tag without changing it child elements visibility? 如何在不更改子元素可见性的情况下为父g标签设置可见性?

Try to use opacity:0 instead of visibility:hidden . 尝试使用opacity:0而不是visibility:hidden

Also, you should look at this example http://svg-whiz.com/svg/HideShow.svg 另外,您应该查看此示例http://svg-whiz.com/svg/HideShow.svg

Hard to understand quite what you are after as the others have said. 就像别人所说的那样,很难理解你的追求。

I had deleted this answer, as it feels I'm missing your point, but thought it may still help http://jsfiddle.net/rnZss/5/ , it will still display the rect, but hide the circle, so I have left the answer for the moment. 我已经删除了此答案,因为感觉我想不到您的意思,但是认为它可能仍然对http://jsfiddle.net/rnZss/5/有所帮助,它仍会显示矩形,但隐藏圆圈,所以我有暂时留下答案。 What else do you want to happen ? 您还想发生什么?

<svg height:"200" width="200">
    <g style="visibility:hidden">
        <g style="visibility:hidden">
            <circle style="visibility: hidden"cx="100" cy="100" fill="green" r="15"/>
            <rect style="visibility: visible" x="50" y="50" width="50" height="50"/>
        </g>
    </g>

</svg>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM