The 2px spaces are actually coming from your markup (there are a bunch of articles on this). If you remove the whitespace between your <li>
elements, the spaces will go away. This is a side effect of making your <li>
elements inline.
The dynamically-created elements don't have this problem, so you're shifting them over 2px too far. To fix it, remove the negative margin completely and either remove the whitespace or float them to the left.