Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/85.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
Javascript TD元素中的图像_Javascript_Html - Fatal编程技术网

Javascript TD元素中的图像

Javascript TD元素中的图像,javascript,html,Javascript,Html,我正在用JavaScript创建一个表 我面临的问题是最后一个带有图像的专栏 已使用显示=块和高度=10% 但这两张图像的大小不同,爆炸程度超过了细胞的正常高度 有什么帮助吗? 图像链接: 代码: 要安装img内部块,请添加类似img fit的类: 此外,尝试使用10vh而不是10%: 参考: 运输署{ 高度:10vh; } .img-fit{ 最大宽度:100%; 最大高度:100%; } 111 222 添加标记/代码、当前输出和预期输出。请提供您的代码和指向您正在谈论的图像的链接。这将使

我正在用JavaScript创建一个表

我面临的问题是最后一个带有图像的专栏 已使用显示=块和高度=10% 但这两张图像的大小不同,爆炸程度超过了细胞的正常高度 有什么帮助吗? 图像链接:

代码:


要安装img内部块,请添加类似img fit的类:

此外,尝试使用10vh而不是10%:

参考:

运输署{ 高度:10vh; } .img-fit{ 最大宽度:100%; 最大高度:100%; } 111 222
添加标记/代码、当前输出和预期输出。请提供您的代码和指向您正在谈论的图像的链接。这将使帮助您更容易。欢迎使用堆栈溢出!在提问之前,请阅读和。我希望第二行和第三行的高度与标题行的高度完全相同。我已经尝试了tForTD.style.maxHeight=50%;但不起作用;omly适用于tForTD.style.maxWidth=50%;但我需要限制这种行为height@MrC有点棘手,如果你确定高度,可能使用50px?我不确定高度不幸的是:有一件事我很困惑:为什么maxWidth工作,而不是maxHeight?@MrC要使用%heigh,你需要定义高度,可能尝试使用vh?
TD = document.createElement("TD");
TD.style.borderWidth="1px";
TD.style.borderStyle="none none inset none";
TD.style.borderColor="#54514e";
TD.style.textAlign="center";
/*
tForTD=document.createTextNode("submit");
*/
tForTD = document.createElement("IMG");
tForTD.setAttribute("src", "Img/submit_2.png");
tForTD.style.backgroundColor="white";
/*
tForTD.style.position="absolute";
tForTD.style.top="0%";
tForTD.style.display="block";
*/
tForTD.style.height="10%";
tForTD.style.borderRadius="50%";
tForTD.style.filter="grayscale(80%)";
tForTD.style.boxShadow="0px 1px 3px 0px black";
/*
tForTD.onclick=  ( function(index) {
return function() { OnClickAddBill(index); };
} )(i);
*/
TD.appendChild(tForTD);
TR.appendChild(TD);
DBT.appendChild(TR);
.img-fit {
  max-width: 100%;
  max-height: 100%;
}