Daily Archives: September 14, 2008

I found the CENTER tag in CSS

I have been hating on CSS because I can’t use the center tag. It is like – just CENTER it DAMN it!
Here is the magic bits:
http://archivist.incutio.com/viewlist/css-discuss/44878
/* Helps IE to center. */
div#outerdiv {
text-align: center;
}
/* The margin version for real CSS savvy browsers. */
div#div_to_be_centered {
text-align: left;
margin: 0 auto;
width: 650px;
padding: 0; /* Zero to prevent IE box trouble. */
}

Warning: Chuck is Starting to Like JQuery

Well I have started hacking on my “next generation LMS” this weekend – I hope to have an early prototype in hand in time for a Monday meeting with the Med school folks. I settled on a framework for the prototype – promise you won’t laugh. JQuery, JSON, PHP, and MySql – yes – I know – so boring. But I can get help from other developers.
And I realized with MySql and the built in PHP5/Apache server on my Apple Laptop – I was nuts to do anything else. I really will miss database portability – for a few minutes :).
So the first part of the weekend is to do some JQuery to build the menu system (isn’t it fun to make really basic stuff at the beginning of a project?). My first reaction to JQuery was “yuck!” – I had seen Prototype in Ruby and loved it – because it did the few things I needed.
When I first saw JQuery, it was like “Where is the simple stuff?” JQuery was a freaking DOM Operating system and all I wanted was a few utility things. And worse – the JQuery documentation does not give simple examples for simple things – the JQ community assumes you are a battle-scarred Javascript guru when you walk in the door.
While the JQ syntax is obtuse, it is far better than the code these gurus wrote previously. For me – I never wrote that complex code – I am just a dummy – I don’t want to learn the nasty way for IE5 and then re-learn the easy JQ way. I just want it easy!
But with a cool mentor like Noah – I get over my mental blocks and get the simple stuff figured out – and once you get the simple stuff working – JQ is a wondrous place. If you wonder how wide the document is, start in Google – look at this page:
http://www.howtocreate.co.uk/tutorials/javascript/browserwindow
Oh yea – who is your Javascript daddy? You need to write case statements within case statements withing case statements. If you are patient and keep googling, you will find this page:
http://plugins.jquery.com/node/1089
A 4K download to find the document width – Better than me writing all the case statements – since the dimensions plugin documentation was not set up for dummies like me – it showed me how to do a million amazing things but not the simple thing I wanted – so I got bored with trying to figure that out – I kept Googling…
And finally I came to this:
alert( $(document).width() );
Uh – this is right there in JQuery 1.2
I can now make my menu dock on the left! Yay!
Note to self: Don’t assume JQuery cannot do something – just keep looking – someone will have blogged a simple JQuery code solution.
The more dummies like me who use JQuery – the more simple examples we will have. Coming up – the simplest JSON / JSONB example you ever saw – I call it the “Missing JQuery tutorial”..