Skip navigation.

v.plonk!

Can't wait to get my hands on the Dragon Age Toolset...

CSSing your my.opera-site - part 6

,

Okay... long time no see, huh? I've been very busy the last few weeks, so I had not much time for some new CSS. Today I took some hours to create a new design, but I'm not really happy about the way it turned out. While Firefox and Safari show the menu just as intended, Opera disables links when you set the font-size to zero, and if you set it to 0.01 (which is close enough to zero so Firefox and Safari still show nothing) it uses the predefined size, at least 1px.

So I wrote a small demand to the my.opera-devs, so they hopefully put the text inside a span-tag so I can format the text dispay:none, while the link itself should still work.


UPDATE:
Thanks to my friend Dasch I was able to fix the menu for Opera. He suggested using a negative text-indent, which in fact was a brilliant idea and worked without any problems at all! :up:
So I decided to call it a usual CSSing lesson now.

BUT I still have something for you... oh yes, I do. I will show you what the usage of "sprites" can do for you... and me... and us too. :wink:


The magic of SPRITES

Let me explain the theory first: If you have several images on the website (especially small icons) that get loaded over and over again, you can either produce several small images OR you put all images in ONE image and just "move" that image in a "picture frame" by chaging it's background position.

You may ask now "what's the deal? I write more code, that's not cool!". You might be right, that you have to write a little bit more code, BUT you load the image in just 1 request, which means that instead of requesting 20-150 images you just ask the server for ONE. Furthermore it drastically improves what we call "caching": That means your browser doesn't load everything from the server everytime, but uses its own memory. That's much faster! You even might be able to write LESS code... :eyes:

Okay, enough theory, let's get to the action:
First we create an image out of our images. I used that sweet young lady you can see in my blog picture (I bought the photos from istockphoto.com , so I think it's okay that I use them here). Then I putted all photos in a larger image, where I can access them by moving up or down inside the picture and I did some image manipulation to make it look better on the background.

Now the code:
#top2 { background: transparent url('SERVER_URL/eyecatcher.jpg') no-repeat; }
.top-blog #top2 { background-position: 375px -1400px; }
.top-archive #top2 { background-position: 375px -1120px; }
.top-albums #top2 { background-position: 375px -840px; }
.top-links #top2 { background-position: 375px -560px; }
.top-friends #top2 { background-position: 375px -280px; }
.top-about #top2 { background-position: 375px 0px; }


Yes... that's all! You see, we even used LESS code, as we only reference one picture instead of six!:wizard:

Okay, let's explain it a bit more: First we define, that we want the picture "eyecatcher.jpg" everytime in the head by giving it as background to the ID top2. Then we do a nice trick: we shift the picture down by defining the background-position, until we reached the "subimage" we want for each part of our blog. So when the guests opens the Links list, he/she will see a different image. Cool? Hot? Both! :yes:

my new laptop could almost hide behind my WiiCSSing your my.opera site - the basic usage

Comments

thobi 24. October 2008, 20:09

THAT design is really cool :up:

David 24. October 2008, 20:54

I think it will take 2 or 3 more CSS sessions til I'm done with the new design. The header was just the beginning. There is more where that came from. :wink:

-( + )- 24. October 2008, 23:40

Do you get money for clicks? I have to visit all your sections to see all the banners. :D
The photo-banner and the blog-banner are my favorites. :up:

An idea for your menu problem: negative text-indent. Is this not possible?

David 25. October 2008, 01:04

@Dasch
You're my hero (don't look at the time I posted), I couldn't sleep with that bug and your ingenious idea solved the problem completely! :yes:

And, no I don't get payed for clicks, but I loved the idea of showing something similar, yet different on every page. I saw one of the photos long ago and this time I just HAD TO make something with it. I guess my theme will be done around next week. With my netbook everything seems so much easier now. :happy:

Besides, I have 1 more image of that series... when my theme is done, I will surely post it or even use it somewhere. flirt

-( + )- 25. October 2008, 02:58

Hehe, a noobs luck. :cheers:

Besides, I have 1 more image of that series... when my theme is done, I will surely post it or even use it somewhere.

Can't wait. :wink:

Lorenzo 27. October 2008, 09:37

I like this design !
But in IE 6 bug I can'not click the Blog, Archive, Photos ... links. In Opera works fine just the mouseover function on Archive is 1 ore more pixel shifted left, Links and Friends on the right.

David 27. October 2008, 11:30

I don't know if I even will try to fix it for IE6 (I can't even test it anymore, as MultipleIE doesn't work on my machine).

I'm aware of the small visual issues, that will get fixed soon (this week). :up:


UPDATE:
The visuals are fixed. :cool:

Donny 27. October 2008, 18:59

Interesting idea for the design.
A bit provocative, but I guess it's in the boundaries of allowed stuff.

It would be good if they added the spans you mentioned, though I am not sure if they will, since that could mess up some designs.

Suntana 28. October 2008, 02:25

Wooooooo! Homer Simpson usually goes, "Mmmm, Cheese!" I'm gonna have to go with, "Mmmm, Chocolate!!! :happy: Heh Heh Heh! I give that Chocolate Show concept the Suntana Seal of Approval. :yes: Can you be selected Member of the Week 2 times in a year? Or at least have Opera come up with a new category - Banner Show Director of the Week? Of the Year? :D

Okay, Chocolate Eye Candy Snack aside ...
Question: I'm not sure if you addressed this between the line somewhere and I missed it.
Say for instance that the original individual Pics were 100K each in size. Once you put them together as 1 Pic, is the New ONE Pic necessarily going to be Number of Pics x Each Pic's Original Size? Or does the multi-Pic morphing into 1 Pic process shave off any size? In other words, if you had Six 100k Pics originally, once they're morphed into 1 Pic, is it just going to be 600K, or do you actually come up with less? I'm especially interested in significantly less. :smile:

This concept is definitely intriguing. I'd certainly be interested in using it. However, with my Dial Up, that's why I'm curious if blending several Pics into one WILL miraculously Hocus Pocus File Size down vs. totalling all the individual Pics' File Sizes. I don't have the luxury of being able to add a significant amount of Bytes to my Blog before I make the loading time too long for my own viewing. :yikes: :lol:

Hey, I did see the difference that Dasche's Tip made! :yes:

David 28. October 2008, 08:27

@Suntana
Significantly less, yes. And I even have a live example for it. You may have seen the colorfoto-creativ.de project I mentioned some posts before? There I used sprites for the very first time. There it's 1 file (54kB) versus 107 files (~180kB). A typical site has around 150 icons, usually around 30 different ones. So that's 30 http requests versus 1. This way we reduced the loading time of each site by around 15-40 times. The key isn't the file size but the http requests. :cool:

And yes... I think 'woman' and 'chocolate' are two words that are bound together. I'm very pleased that so many people like the new 'teaser'. :happy:

Tamil 11. November 2008, 17:34

Lonnie 16. November 2008, 23:47

Excellent CSS David! The web community should be proud, especially us server owners! :yes:

How to use Quote function:

  1. Select some text
  2. Click on the Quote link

Write a comment

Comment
(BBcode and HTML is turned off for anonymous user comments.)

If you can't read the words, press the small reload icon.


Smilies

Download Opera, the fastest and most secure browser