2

i tested ,when running on chrome or firefox, except on ie,
the position:fixed will trigger the display:block?
this the test html :http://sking7.github.com/fix.html
the code will alert two times,the first is display ,the second is document.compatMode
this why?
the w3c has said this ?

SKing7
  • 2,204
  • 4
  • 21
  • 29
  • What version of IE are you using? IE9 returned `block` for me. – jamesplease Oct 11 '12 at 04:56
  • ie9 seem to fix the bug, but why the fixed will trigger the block? – SKing7 Oct 11 '12 at 05:42
  • In my IE8 Standards Mode Chrome tab, this displayed correctly. Maybe your IE is rendering in [quirks mode](http://www.quirksmode.org/css/quirksmode.html)? Just to clarify, that JSFiddle doesn't work for you in IE7 or 8? – jamesplease Oct 11 '12 at 05:46
  • see this test html:http://sking7.github.com/fix.html – SKing7 Oct 11 '12 at 05:59
  • the code will alert two times,the first is display ,the second is document.compatMode – SKing7 Oct 11 '12 at 06:02
  • It's probably some sort of safeguard. Since something that is `position:fixed` is placed relatively to the view port, it has to be `display:block`, otherwise, with an _accurate_ `display:inline`, any fixed element would be at the top left of the page. Which kind of kill the purpose of having it fixed in the first place. And IE was just late in implementing it. – Kraz Oct 11 '12 at 18:09
  • @Kraz but the w3 did not say about this ? – SKing7 Oct 12 '12 at 11:23

1 Answers1

3

Well, I found the w3 specifications for this :

9.7 Relationships between 'display', 'position', and 'float'

The three properties that affect box generation and layout — 'display', 'position', and 'float' — interact as follows:

  1. If 'display' has the value 'none', then 'position' and 'float' do not apply. In this case, the element generates no box.
  2. Otherwise, if 'position' has the value 'absolute' or 'fixed', the box is absolutely positioned, the computed value of 'float' is 'none', and display is set according to the table below. The position of the box will be determined by the 'top', 'right', 'bottom' and 'left' properties and the box's containing block.
  3. Otherwise, if 'float' has a value other than 'none', the box is floated and 'display' is set according to the table below.
  4. Otherwise, if the element is the root element, 'display' is set according to the table below, except that it is undefined in CSS 2.1 whether a specified value of 'list-item' becomes a computed value of 'block' or 'list-item'.
  5. Otherwise, the remaining 'display' property values apply as specified.
Specified value                                     Computed value

inline-table                                        table

*inline*, table-row-group, table-column, 
table-column-group, table-header-group, 
table-footer-group, table-row, table-cell, 
table-caption, inline-block                         *block*

others                                              same as specified
Kraz
  • 6,910
  • 6
  • 42
  • 70