Positioning context on table-cell element in Firefox

后端 未结 1 557
自闭症患者
自闭症患者 2020-12-22 01:15

Usually, we can set a parent element to be the context for a child\'s absolute positioning, as follows:

         


        
相关标签:
1条回答
  • 2020-12-22 02:17

    A table-cell is meant to be inside a table, so:

    See this working Fiddle!

    div {
        display: table;      /* this line */
        line-height: 28px;
        padding: 0 20px;
        background: #ffffd;
        position: relative;
    }
    

    Note: Since you don't have a table in there, set it.

    You can see this quirksmode for the The display declaration.


    EDITED

    From the W3C recommendation :: Tables it reads

    The computed values of properties 'position', 'float', 'margin-*', 'top', 'right', 'bottom', and 'left' on the table element are used on the table wrapper box and not the table box; all other values of non-inheritable properties are used on the table box and not the table wrapper box. (Where the table element's values are not used on the table and table wrapper boxes, the initial values are used instead.)

    This is not a bug, is more like a status-bydesign thing! Please see this!


    EDITED

    To include the work around placed on the comment as requested on the question:

    So, is this a bug? If so, is there anyway to work around it?

    Possible work around are:

    Wrap the element with a div as position:relative; See Fiddle!

    #wrapper {
        position: relative;
    }
    

    Note: most practical solution!

    Wrap the inner elements with a div as position:relative; See Fiddle!

    #innerWrapper {
        position: relative;
    }
    

    Note: requires some definitions from the original element to be declared on the innerWrapper!

    0 讨论(0)
提交回复
热议问题