2017-04-12 52 views
-1

可以說我有這個數445758,我想這些數字是在這樣enter image description here如何製作一個裝滿數字的盒子?

如何做到這一點的盒子嗎?

+0

請提供你已經嘗試過,所以我們可以幫助 –

+0

我沒有這個什麼想法,我還在努力弄清楚 –

+0

您可能需要的JavaScript此代碼..你更喜歡那個嗎? – repzero

回答

1

//conver the number to a string 
 
var num_string=String(445758); 
 
//loop through each character in the string and insert it into a 
 
//div which will be inserted into the document. 
 
for(var x=0;x<num_string.length;++x){ 
 
var box=document.createElement("div"); 
 
box.className="box"; 
 
box.innerHTML=num_string[x] 
 
document.getElementsByClassName("code")[0].appendChild(box); 
 

 
}
.box{ 
 
display:inline-block; 
 
padding:10px; 
 
background:linear-gradient(yellow,white); 
 
margin-right:5px; 
 
margin-left:5px; 
 
}
<div class="code"></div>

+0

非常感謝你@repzero –

+0

總是在這裏幫助.....:D – repzero

+0

不回答一個沒有提供MVCE的問題,只是要求做OP的代碼。 – dippas

相關問題