- This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
Viewing 7 posts - 1 through 7 (of 7 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › Need help in generating blocks with for loop
Hi guys
Try to write a little game in JS using jQuery and I have to generate blocks with js can somebody give me advice how I can do it? Thanks for any help. Have to look something like this http://codepen.io/Kuzyo/pen/zhJxH
Hi!
http://codepen.io/anon/pen/cqrxm
To create new element I used document.createElement method.
After that should set property className to “bricks”
end on the end append new element to relevant conteinter, in your case #field div.
One thing makes me curious. Why the margin of first (not added) elements is bigger than set (1px?)
Someone know?
Thanks @Malgosia appreciate your help. I remove **display: inline-block;** and added **float: left:** to .bricks looks better.http://codepen.io/Kuzyo/pen/zhJxH
So it wasn’t you want to accomplish, right?
Maybe, you tell more about your project to help better understand your problem?
Thanks, everything fine. Here some result, but game don’t get action yet http://jsbin.com/ibufux/3 Do you understand what I’m going to achive?
Ok, now I know what you want to accomplish :)
And I think the better solution would be make bricks positioned absolute.
Because after removing one of them, the rest would be still on the right place.
See my codepen code. Perhaps you find it interesting and it help you.
It is also without action function.
Thanks for the help.