Re: Text metrics with display:none

On Dec 12, 2011, at 6:27 AM, Chris Lilley <chris@w3.org> wrote:

> On Sunday, December 11, 2011, 3:31:41 PM, David wrote:
> 
> DD> Oftentimes I have found myself drawing stuff invisibly first, so
> DD> that I can measure it. Then after knowing how big it will be I position it.
> 
> DD> Centering things relative to one another is difficult in SVG
> DD> (unlike in HTML/CSS), and CSS doesn't seem to help with this issue
> DD> (unless I'm missing something -- and I well may be), so when I
> DD> start finding parts of the spec that tell me I cannot measure
> DD> things unless they are visible, it makes me nervous. I recall a
> DD> similar issue recently with getBBox and leprechaun-nodes. 
> 
> If you want things to be rendered (but invisible) - as opposed to not being in the rendering tree at all, which is what display: none does - then visibility: hidden is what you want.

In HTML it's also position: absolute and top/left offset off screen. It's not an elegant solution but it's been the method for a long time.

It'd be nice to have an elegant solution in the future. These feel like work-arounds for an API that wasn't designed for these use cases.

-Charles

Received on Monday, 12 December 2011 16:05:04 UTC