使用下面的代码,我试图使其打印19张相同的图像,然后将这19张图像作为一个整体在页面上水平居中,但我似乎无法使其正常工作。
var totImg = "large.png";
function prettyHeader(){
function totoroImg(){
var img = document.createElement("img");
img.style.width = "30px";
img.style.height = "30px";
img.src=totImg;
return img;
}
for(var totPrint=0; totPrint<20; totPrint++){
document.body.appendChild(totoroImg());
}
}
prettyHeader();
答案 0 :(得分:0)
var totImg = "https://placeimg.com/30/30/animals";
function prettyHeader(){
function totoroImg(){
var img =document.createElement("img");
img.style.width= "30px";
img.style.height="30px";
img.src=totImg;
return img;
}
for(var totPrint=0; totPrint<20; totPrint++){
document.body.appendChild(totoroImg());
}
}
prettyHeader();
document.body.style = "display: flex; justify-content: center; flex-direction: row";