How to stop table from resizing when contents grow?

前端 未结 6 1893
遥遥无期
遥遥无期 2020-12-09 01:53

I have a table, the cells of which are filled with pictures. I would like the pictures to grow larger when you hover over them and I would like the cells of the

相关标签:
6条回答
  • 2020-12-09 02:10

    use CSS transitions.

    .zoom {
      padding: 50px;
      background-color: green;
      transition: transform .2s; /* Animation */
      width: 200px;
      height: 200px;
      margin: 0 auto;
    }
    
    .zoom:hover {
      transform: scale(1.5); /* (150% zoom - Note: if the zoom is too large, it will go outside of the viewport) */
    }
    <style>
    
    </style>
    
    <p>Hover over the div element.</p>
      <table>
      <tbody>
      <tr>
      <td>
    <div class="zoom"></div>
    </td>
    <td> test text</td>
    </tr>
    </tbody>
    </table>

    w3Schools zoom hover

    0 讨论(0)
  • 2020-12-09 02:11

    Use table-layout: fixed for your table and some fixed width for table itself and/or its cells.

    0 讨论(0)
  • 2020-12-09 02:18

    Add vertical-align:top to the td elements.

    0 讨论(0)
  • 2020-12-09 02:28

    Use min-width in your cells, look an example here

    .cell1{
    display:table-cell;
    width:100px;
    min-width:100px;
    border: 2px dashed #40f;    
    }
    

    http://jsfiddle.net/Gueorguip13/avzuadhp/3/

    0 讨论(0)
  • 2020-12-09 02:28

    You can do to you can use position,z-index,left,top.

    you should look at this way,

    http://jsfiddle.net/wWTfs/

    0 讨论(0)
  • 2020-12-09 02:32

    Use style="table-layout:fixed;", but this will make text or images overlap with other columns in case it exceed the width. Make sure not to place long text phrases without spaces.

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