Loading...

Friday, July 10, 2009

Graceful 3 column to 2 column to 1 column degradation using CSS

I have been wanting to update my blog profile from rounders3 to something a bit more malleable for some time now.

This week I finally got around to it. You can see the results on this blog. It now degrades gracefully from 3-column to 2-column to 1-column mode.

If you are running the latest Safari/Opera/Firefox/Chrome, you can see it in action - just resize the browser window and the layout goes from 3 column, to 2 columns (with the Twitter/Archives sections moving below the profile) to 1 column (with the footer replaced with a helpful message)

This works on all browsers - except IE of course. Older browsers may require the page to be refreshed.

Also, in Print mode, the columns disappear and the footer is replaced with copyright text.

This is all done using CSS 3 Media Queries. These are not supported in Internet Explorer - even v8. Get The Facts - "Firefox and Chrome have more support for emerging standards like HTML5 and CSS3, but Internet Explorer 8 invested heavily in having world-class, consistent support for the entire CSS2.1 specification." Remember?

How did I actually do this? I started off with the instructions given here. They point out that you can use a CSS left and right float to get a three column layout. They also point out an important fact - in the absence of a float, elements will be displayed in the order they are mentioned. Also, clear can be used to ensure that there are no floating elements next to a given element.

Besides this, we have Media Queries. These allow you to specify your display type (for e.g. print for a printer, handheld for a mobile device etc) as well as query on other things such as screen resolution or browser window size/aspect ratio.

Normally you would expect the iPod to respond to handheld, but unfortunately, Apple ignores the handheld tag. In its place, they ask you to query on screen resolution instead.

Finally a couple of things: if your default specification for an object attempts to float to the left, you can override and move it to the right using the CSS !important qualifier. Also, if two rules with !important are triggered at the same time, the one which occurs first is given priority.

Armed with all this, I could write the following to move to two column mode if the browser Window has less than 1000px (view source on this page to see this code). Notice how I changed the margins to accommodate less space required on the right of main-wrap1 in two column mode.

@media only screen and (max-width: 1000px) {
.sidebar-wrap-left {
margin:15px 0px 0px 20px !important;
}
.sidebar-wrap-right {
clear: both !important;
margin:15px 0px 0px 20px !important;
float:left !important;
}
#main-wrap1 {
margin:15px 20px 0px 290px !important;
}
}
This comes below the above for 600-1000 (Note the overlap):
@media print, handheld, only screen and (max-width: 600px) {
.sidebar-wrap-left {
display: none !important;
}
.sidebar-wrap-right {
display: none !important;
}
#main-wrap1 {
margin:15px 20px 0px 20px !important;
}
}
There were a few more tweaks required. For example, the Footer actually has three different messages inside, one each triggerring on Print, sub-600 and Everything Else. Also, the Google Search box in the header (another addition from my side) is layouted using floats - meaning it doesnt play well with the blog layout by default. I had to add the following to get it working (it had a nonsense tab bar on top that I hated)
#uds-searchControl .gsc-resultsbox-visible {
clear:none !important;
}

#uds-searchControl .gsc-tabsArea {
display:none !important;
}
None of this would have been possible without the amazing Firebug extension - its an invaluable tool for use while designing web pages, allowing you to add/view/remove attributes from an element at the same time showing all the CSS attributes (inherited or direct) applicable to an element.

Not surprisingly, the iPod Touch's browser supports media queries. But, it sticks to the 600-1000 rule no matter what. I was pleasantly surprised to find that my 5800's browser also supports media queries. In retrospecitve, since it does Flash too, maybe I shouldnt have been surprise. The 5800 uses sub-600 in portrait/landscape mode and 600-1000 in landscape fullscreen mode (after refresh - using Older/Newer Posts button.) The 5800's UI fails its back end engine as usual - there is no way to refresh the page while in fullscreen mode. Nokia has been taking quite a beating recently by the way. I don't think they deserve it - the 5800/N97 are pretty decent phones, it just that they suddenly have to compete in a field of handheld computers (which is essence is what the iPhone/Palm Pre etc. are - whatever you may choose to call them)

Lastly, I have been having a lot of trouble with FF 3.5 - it seems VERY slow now, much slower than FF3. Most of my friends have switched to Chrome - maybe I will do so too. People are recommending unusual steps to deal with it - from optimizing FF3.5's SQLite databases to clearing out your Temp Folder, Recycle Bin and Temporary Internet Files - it seems its a bug. Mozilla have to get their act together - Chrome will soon have extension support, and the plight of Nokia and Sony should teach them that people have no brand loyalty in the tech domain.

Sunday, July 5, 2009

July Update

Nokia 5800

Nokia is trying to get its act together on Symbian. Symbian is possibly one of the strangest platforms to exist - one that ensures no consistency across even devices that have the same version of the OS. Nokia also tends to release newer features on newer phones rather than adding them to older phones. While Symbian runs very lightweight and responsive, the sheer popularity and quality of the apps on the iPhone Appstore shows easily the problems faced by developers while trying to use Symbian. From a user POV, consider the horrible Download app used by Nokia (that till recently used to show every single apps as free - only to have the app ask for money on installation)

Nokia is trying to improve on this - by launching the Ovi store, having more frequent firmware updates and now, by decoupling features from the OS. Adobe Flash Lite 3.1 recently became available for download over App Update - independently of the Firmware version. This is followed by the Java runtime being updated to 2.0 again independently of the firmware. This has a frightening disclaimer though - it seems if you interrupt the update, your device may need servicing. I am not risking that on a beta version!

Nokia still needs to work on a few things. Their customer care is one - you cant have the same people who service the 50,000 Rs. 1500 phone owners also try to service the 5000 Rs. 15000 phone owners. In India, Nokia tries to do that - and people tell horror stories of Nokia support as a result. Then there's the region coding issue - Ovi store launched months ago but I STILL don't see the Ovi app in the Download app, so officially, it hasnt hit India as yet. Similarly Firmware - Nokia it seems has 500 different Firmwares for the 5800, with minor tweaks for each country. You can easily change a phone's region code and install another firmware - the hardware is identical! But Nokia still makes you wait months for updates if you live in India.

BTW, it seems you can install Python on the 5800 and then that becomes available as a platform - much like J2ME. Amazing!

Firefox

I am sure many people remember M$'s much maligned Get The Facts campaign, which somehow managed to prove that Linux was 10 times more expensive than Windows 2003 - by comparing the cost of running Windows on Intel Xeons and Linux on a hyper-expensive IBM box. Well, they recently came out with a similar campaign for IE8. IE8 somehow manages to beat Firefox on every single category - and even get a "tie" on "customizability." I don't understand why M$ does these things - surely the negative publicity and ill-will generates through this would annul any advantages. Of course, the Firefox team occasionally does annoying things too.

In any case, I have been using FF3.5 for a week now. The only extension which is not working with it is Block Site. Unfortunately, as noted earlier, the browser offers only minimal memory usage improvements - after a week with it, I find FF3.5 using pretty much the same amount of memory of FF3.

In the meantime, the Mozilla team is rushing ahead on the "customizability" front. They recently introduced JetPack - a sort of hybrid between Greasemonkey and normal Extensions. This allows you to write Javascript/CSS that not only changes a page's look and feel (Greasemonkey) but also interacts with the browser chrome (like an extension). The other interesting thing is the ability to create collections of addons on the Firefox site. This allows you to use the Add On Collector extension to create a set of addons which will get installed together. Check out this link to see some collections assembled by Lifehacker.

Customizability is the crux of reason why I use Firefox - even if its slower, uses more memory, has less features etc, I have it customized way too much to my liking using extensions to giv eup on it. The FF team though has an uphill task - jokes aside, IE8 is the best browser by M$ ever and Chrome/Safari/Opera are definitely tough competitors.

Other Stuff

Lifehacker regularly publishes a Hive Five - a comparison of various software in a category, followed by allowing users to vote on their favorite. A few months ago, they came out with a best of the best post - listing the winners of past Hive Fives. This was updated recently with a updated list of new comparisons added since March. Note that these are not free softwares - these are just the best softwares in each cateory, whether paid or free. They recently came out with a separate set 0f the essential free software which any machine needs - called the Lifehacker pack, much like the Google Pack. Of course there is another way to get all these softwares - you can use a installer app, like RadarSync/FileHippo etc. to download and install these for you. These apps are pretty interesting - they serve the same purpose on Windows that Apt does on Linux. Not too many Windows users (even geeks) know about them though, which often leads to many of my friends claiming that there is no Apt-like option for Windows.

It is now possible to synch Outlook to Google Apps, much like Exchange. This is only for the premium version of Google apps. Considering GMail's UI and feature set, one would expect it to be far more widely used than right now. The reason its not, is first and foremost because most organizations are (rightly) not comfortable having their data on the cloud. Retraining requirements for administrators is a factor too, but I feel that is easier to overcome - its a hinderance not a deal breaker. If Google comes out with a Maill Appliance like they have a Search Appliance, Google Apps would be much more popular in the enterprise.

I downloaded M$ Morro - M$'s free antivirus a few days ago. For some reason, the site was non-functional (possibly due to overload) when I opened it. M$ were only going to allow 100,000 people to download Morro. For some reason, I couldn't download Morro during the timeframe allowed, but my MSN ID got registered as a valid tester and I was able to download it the next day. Not that I have installed it of course - I am fully satisfied with Avast thank you very much

Tuesday, June 30, 2009

Firefox 3.5 Released

Firefox 3.5 has been released. It adds several new features - including private browsing and HTML5 support. One feature I disabled the moment I installed Firefox 3.5 - Geolocation. (See the link, I also updated my tweak guide) The other strange thing - all the buttons in the Google Toolbar disappeared, and whenever I stop moving my mouse, an annoying small yellow box pops up under the cursor. (Update - See the last paragraph in this post)

This time, I didn't have as many extensions die on me as for Firefox 3.0. Automatic Save Folder died, but its usable up to Firefox 3.5b4, so possibly it will be updated to fix this. BlockSite is gone too, but I only use to it block Beacon, so I installed Facebook Beacon Blocker instead. This blocks Beacon, but it doesn't replace links with text or show a warning message on block via address bar. It'll do until BlockSite works again...

Mouse Gestures Redox has an updated version you can download from their site, so does Tab Mix Plus. Unfortunately, I use Widefox and on installing Firefox 3.5, everything went blank. So here's how to get Widefox running on Firefox 3.5:

  1. After installing Firefox 3.5, everything will be blank. Exit Firefox. (Use the Task Manager to make sure it REALLY exits - on my machine it has a nasty habit of running in the background while the window closes)
  2. Go to your profile folder - %USERPROFILE%\Application Data\Mozilla\Firefox\Profiles
  3. There will be a folder called <gibberish>.default. Navigate to it
  4. Navigate to chrome.
  5. Rename userChrome.css to _userChrome.css
  6. Start Firefox
  7. Install the latest TabMixPlus Dev Build
  8. Restart Firefox (make sure)
  9. On restart, TMP will be enabled again. This is important. Do not go to next step unless TMP is enabled first
  10. Shut down Firefox (make sure), rename _userChrome.css back to userChrome.css and follow the instructions here as before.
BTW, if you are installing Widefox for the first time with Firefox 3.5, just install TMP, follow the instructions here (after making sure TMP is working on restart) and then setting up Widefox as per the normal instructions here.

I am noticing Firefox 3.5 use less memory - it also seems faster. Lets see how it goes :) BTW, the Widefox pages are hosted on Googlepages - they will be gone soon. Might be a good idea to copy them to your hard disk :) I have shared them on my Office Live Workspace, just in case.

Update: I just uninstalled Google Toolbar and restarted. The small box is gone. Looks like Google Toolbar is not working well with Firefox 3.5. Lets reinstall and see what happens... Yup - that fixes it!

© New Blogger Templates | Webtalks