Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 根据表格大小调整表格内图像的大小_Html_Css - Fatal编程技术网

Html 根据表格大小调整表格内图像的大小

Html 根据表格大小调整表格内图像的大小,html,css,Html,Css,我有一张桌子,里面放着图像。一些图像将大于桌子的宽度(高度无关紧要)。我正在寻找一种方法来保持图像与桌子的大小相同,而不拉伸桌子。我不想将图像宽度设置为100%,因为如果图像小于表格宽度,则会使图像变宽。此外,我希望比例保持不变。有什么想法吗?使用css 示例:style.css(二者之一) 关于“img”通过指定高度或宽度 img { max-height:50px; } 关于td或th中的表(取决于您是否使用th) 阅读此处的指南:将img的高度调整为的高度,例如: tr { he

我有一张桌子,里面放着图像。一些图像将大于桌子的宽度(高度无关紧要)。我正在寻找一种方法来保持图像与桌子的大小相同,而不拉伸桌子。我不想将图像宽度设置为100%,因为如果图像小于表格宽度,则会使图像变宽。此外,我希望比例保持不变。有什么想法吗?

使用css

示例:style.css(二者之一)

关于“img”通过指定高度或宽度

img {
   max-height:50px;
}

关于tdth中的表(取决于您是否使用th)


阅读此处的指南:

将img的高度调整为
的高度,例如:

tr {
height:40px;
}
tr img{
height:40px;
}

你需要CSS。。将样式设置为img:最大宽度:100%;最大高度:100%;我添加了样式,但没有调整任何图像的大小。一定有什么我遗漏了。这是我得到的。。。img{max height:50px;}尝试检查扩展名文件是否为“GIF”、“JPG”、“PNG”…但我的工作正常。。。示例Img定标器Img{max height:50px;}对我有效。我想出于某种原因,我不得不把这种风格放在同一行。weirdif它起作用了,那么你可以检查/或+1,这样客人就可以知道解决方案在哪里了
tr {
height:40px;
}
tr img{
height:40px;
}