firefox position absolute inside a relative container issue

前端 未结 5 1142
失恋的感觉
失恋的感觉 2020-12-08 05:23

i am using table for displaying my dynamically generated data depend upon the user input the html structure is looks like below:

相关标签:
5条回答
  • 2020-12-08 05:33

    I solved the problem adding display: block;

    .table td div {
      position:absolute;
      display:block;
    }
    

    in your case:

    <table>
    <tr>
        <td>.....</td>
        <td>.....</td>
        <td style="position:relative;"> <!-- like this i set for all td in table -->
         <div style="position:absolute; display:block"> <!-- like this i set for all div in table -->
         <contents>
         </div>
       </td>
       <td>.....</td>
       <td>.....</td>
    </tr>
    </table>
    
    0 讨论(0)
  • 2020-12-08 05:38

    Positioning of table cells is problematic. The usual solution is to leave the style of the td alone, and put a div in it which you make position:relative. Then place the content inside that div.

    <td> <!-- no style at all -->
     <div style="position:relative;">
      <div style="position:absolute"> <!-- original div -->
       <contents>
      </div>
     </div>
    </td>
    

    Edit:
    I don't know which effect you're after, but here's a jsFiddle demonstrating the problem: http://jsfiddle.net/ygP7k/5/
    It has a table with little absolutely positioned divs in each table cell, that are supposed to align to the bottom right corners. It works in all browsers except Mozilla ones.

    But here is an updated one with the extra divs as I mentioned: http://jsfiddle.net/ygP7k/7/
    This works exactly the same, except that it also does the trick in Firefox.

    Can you work with this? Does this answer your question?

    0 讨论(0)
  • 2020-12-08 05:39

    I had a similar problem. I wrapped the problematic absolute div in an absolute div which fixed the issue:

        <div class="thumbnail" style="..position:relative;..">  
            <div style="position:absolute;">
            <div class="thumbnail-heart" style="..position:absolute;..">
                <img src="../image.png" style="float:right;position:relative;..">
                ...
            </div>
            </div>
    
    0 讨论(0)
  • 2020-12-08 05:45

    I looked at the hoverplus jQuery plugin and the source file shows the method used:

    // parent must be relatively positioned
    this.parent().css({ position: 'relative' });
    
    // pulsing element must be absolutely positioned
    this.css({ position: 'absolute', top: 0, left: 0 });
    

    Because of this plugin's requirements and your current design needs, I recommend using .transit() jQuery plugin that has powerful and easy to use Zoom features without such requirements.

    I prepared two Table Examples, each with 9 Div's and as you can see by the markup, it can't be any easier!

    jsFiddle DEMO of Zoomed Div's with Images in Tables

    After you take a look at the jsFiddle I made for you, you can see all .transit() plugin features on the demo page HERE.

    EDIT: The jsFiddle now has required CSS style for td tag of position:relative per your update.

    0 讨论(0)
  • 2020-12-08 05:45

    you have to add 2 div in Table 1 with position:relative and 2nd with position:absolute

    <td>
    <div style="position:relative">
    <div style="position:absolute">ffffd</div>
    </div>
    </td>
    

    your problem will be solved check fiddle

    http://jsfiddle.net/rizwanabbasi/2hyE8/1/

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