![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
The 'top' and 'bottom' properties move relatively positioned element(s) up or down without changing their size. 'top' moves the boxes down, and 'bottom' moves them up. Since boxes are not split or stretched as a result of 'top' or 'bottom', the computed values are always: top = -bottom. If both are 'auto', their computed values are both '0'. If one of them is 'auto', it becomes the negative of the other. If neither is 'auto', 'bottom' is ignored (i.e., the computed value of 'bottom' will be minus the value of 'top'). |
#2
| |||
| |||
|
|
Opera 10.1 has a buggy implementation of getComputedStyle top. I've noticed now that getting the top value for an LI, in normal flow, returns what would be an in-flow offset y coordinate. Not surprising. I noticed a similar bug years ago in Opera. URL:http://dhtmlkitchen.com/?category=/Browsers/&date=2007/11/08/&entry=O... (messy URI and latency, probably due to my configuration of Blojsom); In the following example, the "top" value for each LI should be "auto" or 0, based on the definition of absolute value for top in CSS 2[1]. Definitions of "absolute value" changed from CSS 2 to CSS 2.1. Result: * *Firefox: * *"0px" * *Chrome 2: * "auto" * *Opera 10.1: "133px" What the fuck? |
#3
| |||
| |||
|
|
On Nov 1, 1:03 am, Garrett Smith <dhtmlkitc... (AT) gmail (DOT) com> wrote: Opera 10.1 has a buggy implementation of getComputedStyle top. [...] In the following example, the "top" value for each LI should be "auto" or 0, based on the definition of absolute value for top in CSS 2[1]. Definitions of "absolute value" changed from CSS 2 to CSS 2.1. Result: Firefox: "0px" Chrome 2: "auto" Opera 10.1: "133px" What the fuck? Two words: who cares? |
|
item down two pixels, you would add two to whatever is there. In the case of "auto" you would assume 0. GIGO. |
|
If instead you are interested in the offset position, use offsetLeft/ Top, preferably within the confines of a positioned parent element. OffsetLeft and offsetTop are not standard. That approach works for UL, |
#4
| |||
| |||
|
|
(...) (meanwhile Apple, aka "those scumbags in Cupertino" |
|
are patenting CSS animations (...) |
|
and Touch events (...) |
#5
| |||
| |||
|
#6
| |||
| |||
|
|
On Nov 1, 6:03 am, Garrett Smith <dhtmlkitc... (AT) gmail (DOT) com> wrote: (...) (meanwhile Apple, aka "those scumbags in Cupertino" No news about the scumbags in Redmond (WA, USA), Espoo (FIN) or Waterloo (CA), right ? |
|
See Maciej's response to Olli's "I was a bit afraid of that Apple might have done something evil like this": http://lists.w3.org/Archives/Public/www-dom/2009OctDec/0034.html quote I note that Apple is a member of the Web Apps Working Group and thus subject to the W3C Patent Policy with respect to Web Apps WG deliverables. I can't comment on whether Apple would exclude any patent claims relating to this area, if they turn out to be essential claims. /quote |
#7
| ||||
| ||||
|
|
David Mark wrote: On Nov 1, 1:03 am, Garrett Smith <dhtmlkitc... (AT) gmail (DOT) com> wrote: Opera 10.1 has a buggy implementation of getComputedStyle top. [...] In the following example, the "top" value for each LI should be "auto" or 0, based on the definition of absolute value for top in CSS 2[1]. Definitions of "absolute value" changed from CSS 2 to CSS 2.1. Result: * *Firefox: * *"0px" * *Chrome 2: * "auto" * *Opera 10.1: "133px" What the fuck? Two words: who cares? * The latest versions of the most popular, and mature browsers not following 10yr old standards? Yeah, I care about that. |
|
In more than 10 years, there is not a way to read an element's style value, cross browser. It is a problem. Given the rate of progress by the (useless individuals in the CSSWG), there is no foreseeable change on the horizon. *That* is a worse problem. If you wanted to - for example - move the list item down two pixels, you would add two to whatever is there. *In the case of "auto" you would assume 0. *GIGO. Is the answer to the question: How can I position an element. Who asked? I would not assume "0" for auto, because I read the specification (indeed I cited it on this very thread) and I understand that such assumption would be incorrect. "auto" is not 0. |
|
If instead you are interested in the offset position, use offsetLeft/ Top, preferably within the confines of a positioned parent element. OffsetLeft and offsetTop are not standard. That approach works for UL, but not other elements, such as TD (I recall problems with Safari 2). |
|
Oddly, what Opera returns for the computed style string + "px" for the value that you have described as "the offset position from the positioned parent element." |
#8
| |||
| |||
|
|
Oddly, what Opera returns for the computed style string + "px" for the value that you have described as "the offset position from the positioned parent element." |
#9
| ||||||||||
| ||||||||||
|
|
On Nov 1, 2:22 am, Garrett Smith <dhtmlkitc... (AT) gmail (DOT) com> wrote: David Mark wrote: On Nov 1, 1:03 am, Garrett Smith <dhtmlkitc... (AT) gmail (DOT) com> wrote: Opera 10.1 has a buggy implementation of getComputedStyle top. [...] [...] |
|
If you wanted to - for example - move the list item down two pixels, you would add two to whatever is there. In the case of "auto" you would assume 0. GIGO. Is the answer to the question: How can I position an element. Who asked? I would not assume "0" for auto, because I read the specification (indeed I cited it on this very thread) and I understand that such assumption would be incorrect. "auto" is not 0. Doesn't matter. I wouldn't bother memorizing such useless trivia as "auto" is not a computed style at all. If you run into walls like this, change direction. |
|
If instead you are interested in the offset position, use offsetLeft/ Top, preferably within the confines of a positioned parent element. OffsetLeft and offsetTop are not standard. That approach works for UL, but not other elements, such as TD (I recall problems with Safari 2). Works great within a positioned parent. Doesn't matter if they are real standards (yet). If you try to measure all the way to the root of the document, you are going to end up with a lot of code. |
|
Oddly, what Opera returns for the computed style string + "px" for the value that you have described as "the offset position from the positioned parent element." Again, who cares what they say (or do?) The computed left/top of a relatively positioned element is not something you should rely on. That's always been the case, driven home by Opera more than once. |
|
Computed value: for 'position:relative', see section Relative Positioning. For 'position:static', 'auto'. Otherwise: if specified as a length, the corresponding absolute length; if specified as a percentage, the specified value; otherwise, 'auto'. |
|
2.2.1. Override and computed style sheet Interface ViewCSS (introduced in DOM Level 2) This interface represents a CSS view. The getComputedStyle method provides a read only access to the _computed values_ of an element. |
|
Specified values may be absolute (i.e., they are not specified relative to another value, as in 'red' or '2mm') or relative (i.e., they are specified relative to another value, as in 'auto', '2em', and '12%'). For absolute values, no computation is needed to find the computed value. Relative values, on the other hand, must be transformed into computed values: percentages must be multiplied by a reference value (each property defines which value that is), values with relative units (em, ex, px) must be made absolute by multiplying with the appropriate font or pixel size, 'auto' values must be computed by the formulas given with each property, certain keywords ('smaller', 'bolder', 'inherit') must be replaced according to their definitions. |
|
When the specified value is not 'inherit', the computed value of a property is determined as specified by the Computed Value line in the definition of the property. |
|
Computed value: for 'position:relative', see section Relative Positioning. For 'position:static', 'auto'. Otherwise: if specified as a length, the corresponding absolute length; if specified as a percentage, the specified value; otherwise, 'auto'. |
|
The 'top' and 'bottom' properties move relatively positioned element(s) up or down without changing their size. 'top' moves the boxes down, and 'bottom' moves them up. Since boxes are not split or stretched as a result of 'top' or 'bottom', the computed values are always: top = -bottom. If both are 'auto', their computed values are both '0'. If one of them is 'auto', it becomes the negative of the other. If neither is 'auto', 'bottom' is ignored (i.e., the computed value of 'bottom' will be minus the value of 'top'). |
#10
| ||||||||||||||||
| ||||||||||||||||
|
|
David Mark wrote: On Nov 1, 2:22 am, Garrett Smith <dhtmlkitc... (AT) gmail (DOT) com> wrote: David Mark wrote: On Nov 1, 1:03 am, Garrett Smith <dhtmlkitc... (AT) gmail (DOT) com> wrote: Opera 10.1 has a buggy implementation of getComputedStyle top. [...] [...] follow up to comp.infosystems.www.authoring.stylesheets (this is more of a CSS topic). |
| If you wanted to - for example - move the list item down two pixels, you would add two to whatever is there. *In the case of "auto" you would assume 0. *GIGO. Is the answer to the question: How can I position an element. Who asked? I would not assume "0" for auto, because I read the specification (indeed I cited it on this very thread) and I understand that such assumption would be incorrect. "auto" is not 0. Doesn't matter. *I wouldn't bother memorizing such useless trivia as "auto" is not a computed style at all. *If you run into walls like this, change direction. No need to memorize, the specification is publicly available. I linked to it earlier in this thread. |
|
It is too complicated to memorize. Things that make sense conceptually (patterns or formulas) seem easier memorize. Anyone may read it. |
|
If instead you are interested in the offset position, use offsetLeft/ Top, preferably within the confines of a positioned parent element. OffsetLeft and offsetTop are not standard. That approach works for UL, but not other elements, such as TD (I recall problems with Safari 2). Works great within a positioned parent. *Doesn't matter if they are real standards (yet). *If you try to measure all the way to the root of the document, you are going to end up with a lot of code. How about Safari 2, inside a TD? |
|
Nonstandard properties are problematic because they often get copied in ways that are different from the original. |
|
The result is a sort of "mystery meat" property which may mean any things in many contexts. |
|
OffsetTop is the poster child for mystery meat properties. |

|
I explained that problem to VK recently. |
|
Oddly, what Opera returns for the computed style string + "px" for the value that you have described as "the offset position from the positioned parent element." Again, who cares what they say (or do?) *The computed left/top of a relatively positioned element is not something you should rely on. That's always been the case, driven home by Opera more than once. Generally standards approach should be favored over proprietary, nonstandard properties. |
|
The computed style is standard and specified. The value "auto" is a standard and specified value for computed style for top. |
|
That is clearly stated in the link to CSS2 spec that I provided earlier.http://www.w3.org/TR/CSS2/visuren.html#position-props | Computed value: for 'position:relative', see section Relative | Positioning. For 'position:static', 'auto'. Otherwise: if specified as | a length, the corresponding absolute length; if specified as a | percentage, the specified value; otherwise, 'auto'. So for "position: static", the expected computed value is "auto". |
|
Method getComputedStyle should indeed return that value, as stated in DOM 2 StyleSheets[1]:http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-OverrideAndComputed |

|
| 2.2.1. Override and computed style sheet | | Interface ViewCSS (introduced in DOM Level 2) | | *This interface represents a CSS view. The getComputedStyle method | provides a read only access to the _computed values_ of an element. |
|
That leads to the definition of "computed values". That definition varies between CSS2 and CSS2.1: CSS2:http://www.w3.org/TR/1998/REC-CSS2-19980512/cascade.html#computed-value |
|
| Specified values may be absolute (i.e., they are not specified | relative to another value, as in 'red' or '2mm') or relative (i.e., | they are specified relative to another value, as in 'auto', '2em', and | '12%'). For absolute values, no computation is needed to find the | computed value. | | Relative values, on the other hand, must be transformed into computed | values: percentages must be multiplied by a reference value (each | property defines which value that is), values with relative units (em, | ex, px) must be made absolute by multiplying with the appropriate font | or pixel size, 'auto' values must be computed by the formulas given | with each property, certain keywords ('smaller', 'bolder', 'inherit') | must be replaced according to their definitions. CSS2.1http://www.w3.org/TR/CSS21/cascade.html#computed-value | When the specified value is not 'inherit', the computed value of a | property is determined as specified by the Computed Value line in the | definition of the property. The definition for Computed Value, for |top|, one more time: |
|
In many browsers, getComputedStyle returns used values for some properties. The used value and the computed value are not the same thing.http://www.w3.org/TR/CSS2/cascade.html#used-value |
![]() |
| Thread Tools | |
| Display Modes | |
| |