Hola. I'm Olof and I make stuff for the web. How can I help you?

Flexible auto-width fonts with CSS and jQuery

There’s a lot of situations where you design or develop something with fixed width. Let me give you an example.

Say you have a form with two columns. Your left column holds a label, ”Addictive”, and your right column holds a textbox. In most of the cases you probably set a fixed width for the left column. But what if your site fetches the label text depending on what language your user has chosen? And what if the translation is a lot bigger than the original?

For instance, ”Addictive” in English is ”Beroendeframkallande” in Swedish (yup, that’s one large word, or actually 2 words put together). That will make your little label-div trying to break lines and ultimately mess up the look of your page.

Apples iProducts has a great implementation of this and an easy way to find it is to compose a new e-mail and start writing in the to-input. The longer the e-mail get, the smaller the font-size.

I ran into this little smart jQuery Plugin called Fit Text that looks very promising. Go have a look!

CSS Browser Detection

A technique I used for quite some time is to detect the browser and add an appropriate class to the body-element. I used this mostly to differentiate IE-versions and add appropriate styles to elements that got screwed up. Two examples.

A windows machine with Internet Explorer 7:
<body class=”ie ie7 win”> 

A windows machine with Firefox 4:
<body class=”ff ff4 win”>

Today I ran into a small script that makes this possible (and even add some more properties). It’s a variant of modernizr but a bit smaller and just for detecting the browsers. 

Check it out at: https://github.com/rafaelp/css_browser_selector

Mobile website versus mobile app

You need to consider the pros and cons of building a mobile website or a mobile app (native). I found a good post form Adobe on this matter, have a look! 

http://www.adobe.com/newsletters/inspire/february2012/articles/article7/

 

25 jQuery Plugins to help with responsive layouts.

We need to better adjust our layout depending on what device the customer uses. I’m still thinking about an iPhone version of this site, eventhough it’s ”OK” in the browser from start. 

Have a look at this top 25 list for some ideas. 

http://speckyboy.com/2011/10/24/25-jquery-plugins-to-help-with-responsive-layouts/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+veerlesblog+Veerle%27s+Blog+3.0+-+All&utm_content=Google+Reader#When:17:33

Öredev Creative Javascript and HTML5

You will find me taking a crash-course in Creative Javascript and HTML5 at the Oredev conference 7th and 8th of November. Would be lovely to catch up with some other web developers just like me so please let me know if you will attend. I will write a post later on what I learned.

LESS – Another way to do CSS

We all love CSS and the power it gives to you. Still there’s a couple of features that would be great extensions. Have a look at the LESS framework and see how you can extend your CSS-code in a smart way http://coding.smashingmagazine.com/2011/09/09/an-introduction-to-less-and-comparison-to-sass/

Extend jQuery with .toggleAttr()

As far as I know there is no way to toggle an attribute, such as an input disabled attribute. Extend with this to get it quick and nicely:

$.fn.extend({
  toggleAttr : function( attrib ) {
    if ( this.attr( attrib ) ) {
      this.removeAttr( attrib );
    } else {
      this.attr( attrib, attrib );
    }
    return this;
  }
});

Avoiding common HTML5 mistakes

I bet you’re all as curious as me on the HTML5 framework. However the transition might not be that straight-forward as you think. This is a post about what you’re not supposed to do.

http://html5doctor.com/avoiding-common-html5-mistakes/ 

Javascript MVC

Currently experimenting with the Javascript MVC framework. Looks very promising for bigger enterprise projects.

By splitting functions into modules you are able to test them solo.

Currently experimenting with the Javascript MVC framework. Looks very promising for bigger enterprise projects.

By splitting functions into modules you are able to test them solo