zur4ik
zur4ik

Reputation: 6254

CSS absolute positioned object inside table-cell displayed object in Firefox

I have big trouble with CSS positioning with absolute element inside display:table-cell object. All browsers render correctly except Firefox.

My HTML looks like this:

<ul class="slider">
    <li rel="sl1">
        <span class="sltitle">Item 1</span>
        <span class="pointer"></span>
    </li>
    <li rel="sl2">
        <span class="sltitle">Item 2</span>
        <span class="pointer"></span>
    </li>
    <li rel="sl3">
        <span class="sltitle">Item 3</span>
        <span class="pointer"></span>
    </li>
</ul>

and CSS:

.slider {
    list-style: none;
    display: table;
    width: 100%;
    height: 100%;
    position: relative;
}

.slider li  {
    display: table-cell;
    border: 1px solid #1C1A1A;
    position: relative;
    overflow: hidden;
}

.slider li span.pointer {
    display: block;
    border: 1px solid red;
    width: 100%;
    height: 100%;
    cursor: pointer;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 99;
}

Here is the JSFIDDLE for that: http://jsfiddle.net/zur4ik/SN7zL/

Please open this link in Chrome and then in Firefox, you'll see the difference. Do you know any proper way how to fix this issuer?

Upvotes: 0

Views: 1572

Answers (2)

WaNgeL
WaNgeL

Reputation: 198

May be it's problem grow from this problem - Does Firefox support position: relative on table elements?

And - Positioning context on table-cell element in Firefox

Wrap the element with a div as position:relative.

http://jsfiddle.net/N6bUU/2/

.rel {
    position:relative;
    display:block;
    height: 100%;
    width:100%;
}

Upvotes: 1

Pete
Pete

Reputation: 58462

Firefox has issues with absolute positioning and display:table-cell - see this

You need to wrap the element in a block element with relative positioning and then it will work:

Example

Upvotes: 3

Related Questions