<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>无标题文档</title> <style> div { width:50px; height:50px; background:red; position:absolute; top:0; left:0; font-size:30px; text-align:center; line-height:50px; color:#fff; } </style> <script> window.onload = function (){ var aDiv = document.getElementsByTagName('div'); for( var i=0; i<50; i++ ){ document.body.innerHTML += '<div>' + i + '</div>'; } for( var i=0; i<aDiv.length; i++ ){ aDiv[i].style.left = 10 + i*60 + 'px'; //应该不是像我这样写的吧.... for (var j = 10; j < 20; j++) { aDiv[j].style.top = 60 + 'px'; aDiv[j].style.left = 10 + (j-10)*60 + 'px'; } for (var j = 20; j < 30; j++) { aDiv[j].style.top = 120 + 'px'; aDiv[j].style.left = 10 + (j-20)*60 + 'px'; } } }; </script> </head> <body> </body> </html>
50个方形div,10个一组,排成5行怎么写?
慕粉4075985
习惯受伤
慕婉清5044891
hulukid
相关分类