Category ‘Web Development’

9-slice scaling in HTML

15 . May 2008
written by Clemens Lang at May 15th 2008, 16:59

9-slice scaling is a technique from Adobe’s Flash product line and has been adapted into Fireworks. It is used to scale certain parts of a symbol different from others when resizing the symbol (i.e. not scaling the corners at all) to make corners and borders look the same at every size of the symbol. With a little CSS and HTML this can be done in browsers, too.

The Adobe Fireworks help has a good article explaining 9-slice scaling. Now imagine you’re designing a liquid width layout for a website - wouldn’t it just be great if it would scale as it was 9-sliced? Here’s how:

Slicing

First you need one image for each of the outer areas in the 9-slice grid. That’s top left, top center, top right, left center, right center, bottom left, bottom center and bottom right. We don’t need an image for the center, since it’s filled with one solid color in this example and we can use CSS for that. Note that all top and all bottom slices must share the same height. The top center and bottom center slices should be 1 pixel wide, since we’re not going to scale them, but repeat them (which is the difference of this technique compared to the original 9-slice scaling). Left and right center slices only need to be 1 pixel high for the reasons just mentioned.
After all, the slicing looks like this (forgive me the typo):
image

HTML code

Here’s the HTML you’ll need. Read the comments in the code for explanation.

  1. <div class="content">
  2. <!-- this is the overall container -->
  3. <div class="content-top">
  4. <!-- this contains the top left, top right and top center slices -->
  5. <div class="content-top-left"></div>
  6. <div class="content-top-right"></div>
  7. <!-- notice the top center or top repeat slice needs to be at the end -->
  8. <div class="content-top-repeat"></div>
  9. </div>
  10. <div class="content-repeat">
  11. <!-- this is just a container for the vertically scaling part - you could leave it out, but it seems cleaner to me -->
  12. <div class="content-repeat-left">
  13. <div class="content-repeat-right">
  14. <!-- in this case the left center and right center must be nested and must contain the actual content div, so they automatically scale with it -->
  15. <div class="content-repeat-center">
  16. <!-- /** this is where you'd place the content **/ -->
  17. <div class="content-repeat-clearfix"><!-- this will prevent problems with floated stuff within the content --></div>
  18. </div>
  19. </div>
  20. </div>
  21. </div>
  22. <div class="content-bottom">
  23. <!-- this contains the bottom left, bottom right and bottom center slices -->
  24. <div class="content-bottom-left"></div>
  25. <div class="content-bottom-right"></div>
  26. <!-- as above the bottom center div must be after the bottom left and right divs -->
  27. <div class="content-bottom-repeat"></div>
  28. </div>
  29. </div>
  30.  

Read the rest of this entry »

Up or Out: employees in IT companies quitting

30 . April 2008
written by Clemens Lang at Apr 30th 2008, 21:14

I just read an article in Alex’ Soapbox on IT professionals and their motives to quit a job at a certain company. Having just finished a 6-month-internship at a local new media agency this article came right on time. I don’t want to judge neither the article nor the company I’ve been working at, but the theory mentioned in “Up or Out: Solving the IT turnover crisis” is absolutely worth reading if you haven’t already.
Personally I think Alex Papadimoulis’ findings are a bit too black-and-white (as he admits near the end of the article: “Obviously, this article has painted some incredibly broad strokes, the largest being the stark dichotomy between skilled and unskilled developers, and the lack of distinction between organizations.”), but they are true nonetheless.

The smaller the error the bigger the bug

26 . April 2008
written by Clemens Lang at Apr 26th 2008, 12:05

Bug tracking in software development can be a pain - especially when there doesn’t seem to be any logic behind the bug.

So we had that navigation tree at work consisting out of two category levels, for simplicity let’s call them Level-1-Category and Level-2-Category. Level-1-Categories could contain other Level-1-Categories and Level-2-Categories, while Level-2-Categories could only contain Level-2-Categories. The navigation was built, caching was implemented, everything seemed fine from a logic viewpoint, however it behaved weird where it would sometimes display the Level-2-Categories in a particular Level-1-Category and sometimes not or in different order.
When we finally found the bug (after hours of debugging) the scales fell off our eyes:

  1. <?php $cacheID = md5($level1Cat->id.$level2Cat->id); ?>

Now imagine what happened when you had a $level1Cat with ID 1 and a $level2Cat with ID 12, that would write it’s cache to md5(‘112’); - and trying to open a $level1Cat with ID 11 and a $level2Cat with ID 2 it would read the cache md5(‘112’);. Unfortunately these classes did have the same interface, so no errors were thrown.
Changing the code to
  1. <?php $cacheID = md5($level1Cat->id.'-'.$level2Cat->id); ?>
resolved the bug and finally fired the closing time-event for us.

 <  1 2 3 4 5 >  Last »