内容增长时如何阻止表格调整大小? [英] How to stop table from resizing when contents grow?
问题描述
我有一个表
,其中的单元格填充图片。我想让图片变大时,你悬停在他们,我希望表的单元格保持在相同的大小。
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 table to remain at the same size.
将 img
样式更改为 position:relative
不工作。更改为 position:absolute
可以工作,但我不知道图像的绝对位置。
Changing the img
style to position:relative
doesn't work. Changing it to position:absolute
does work, but I don't know the absolute position of the images.
使用CSS有这个问题的优雅解决方案吗?我宁愿不使用任何JavaScript。
Is there an elegant solution to this problem using CSS? I'd rather not use any JavaScript.
推荐答案
使用 style =table-layout:fixed;
但这将使文本或图像与其他列重叠,以防万一超过宽度。请确保不要在空白处放置较长的短语。
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.
这篇关于内容增长时如何阻止表格调整大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!