You're all fixed up. You had conflict after conflict in your code and it was literally wrapping the page in knots.
It's not usually necessary to have both a <div> and <table> statement, because, really, a table is just a sepcialised div. The div wasn't closed (</div>) so this caused one headache. You've pretty much always got to close a div once you've opened it, or the page will just slide around. A big tip off that you haven't closed your div is that the right rail (the column with the search bar and recent wiki activity) will slide down under the main article.
I strongly urge you to go with either all wikitext markup (as seen at tardis:T:TABLES), or go with all HTML. Combining the two almost always creates unpredictable results.
No worries. Reverse engineering is how one learns best. Now take a look at this: w:c:pybot:template:infobox. It's all in wikitext and it's therefore easy to read and troubleshoot. There's no styling at all in the template code. All the styling is tucked away at w:c:pybot:MediaWiki:Common.css.