Pure CSS Coke Can
25 de Enero del 2010
(versión en castellano abajo)
After doing the CSS Paper Bird effect, I found out that by a combination of the CSS1 properties background-attachment and background-position, 2D displacement maps could be created and, by scrolling, the displacement map would be applied to different parts of the texture (a background image).
With displacement maps lots of cool effects could be done, but thinking that the complexity of the displacement map would directly affect the CSS and markup size, choosing a good example took me some time. I thought in sea waves reflections, underwater distortions, magnifying glass, a rotating Earth… but the final thing I did was just right in my desktop: a Coke can - my favourite drink.
Due the cilindrical shape of a can, the displacement map is very simple with the parallel projection I did, so the code is very little - below 5kb - and easy to understand I hope.
Even if this effect is mainly CSS1 and some bits of CSS2 - for the scrolling div, overflow: auto property -, it is not going to work in IE6, because it doesn’t support background-attachment: fixed. I’ve tested it and it works in IE8, Firefox 3.5, Chrome 3, Safari 4 and Opera 10. Also, the code validates.
Castellano
Tras crear mi anterior efecto (post anterior a este), describí que con una combinación de las propiedades CSS1 background-attachment y background-position, se pueden crear mapas de desplazamiento y, mediante barras de scroll, estos mapas pueden moverse y aplicarse a diferentes partes de una textura (una imagen de fondo).
Con los mapas de desplazamientos se pueden hacer una gran cantidad de efectos interesantes, pero la complejidad del mapa afecta directamente al tamaño del código HTML y CSS. Encontrar un ejemplo apropiado cuya tamaño de código no fuese muy grande pero que produjese un efecto interesante me llevó algo de tiempo. Tras pensar en reflejos de olas, distorsiones submarinas, efecto lupa, la Tierra rotando, finalmente encontré el mejor ejemplo justo encima de mi mesa: una lata de Cola-Cola (mi bebida favorita).
Debido a la forma cilíndrica de la lata, el mapa de desplazamiento es sencillo con la proyección paralela que hice en el ejemplo, y por tanto el código es muy pequeño (menos de 5kb) y fácil de entender (espero).
Pese a que el ejemplo funciona principalmente con CSS1 (y overflow: auto de CSS2), no funcionará en IE6; no soporta la propiedad background-attachment: fixed. Lo he probado en los navegadores actuales y funciona correctamente, y el código valida.

Woow eh seguido tu blog desde hace un tiempo y las cosas que haces son impresionantes y muchas veces inimaginables, sigue asi!!!
¡Yo lo vi primero! jajaja, éste me gusta más que el de las Meninas. De nuevo, enhorabuena ;-)
Amazing what you can do with a few tricks. Very nice work :D
ALAAA!! los anteriores estan fenomenos, pero la sensación de perspectiva del cilindro está fabulosa!! estuve rompiendome los cuernos con el css. Muy ingenioso, si señor :)
Verdaderamente puro CSS, nada de javaSript. El codigo es muy simple y contrasta con un efecto tan logrado. Supongo que fue un gran esfuerzo hallar los ‘width’ que encanjan. Puro CSS y puro pensamiento lateral.
Cool! Can the pop-top of the coke can pop up while copping out at a time?
[…] full post on Hacker News If you enjoyed this article, please consider sharing it! Tagged with: Effect • […]
Muito bom! Estou impressionado com este efeito!
wow! amazing! css is cool))
NNNNiiice !!
Already tried automating the movement thru jquery.. must be possible no ?
T.
Это круто.Респект.
Fantastic work! Did a great job with ‘backgrounded paragraph’ thing! : D
awersome! css guru :)
Nice… I used the same frame based approach, but with JavaScript ;D http://finnrudolph.de/JavaScriptObject
Genial!! y lo mejor es el código, simple :D
Como dice Esteban, un gran esfuerzo para poder colocar bien las imágenes
[…] Lata de Coca-cola 100% CSS http://www.romancortes.com/blog/pure-css-coke-can/ por Dead_Parrot el 16:36 UTC […]
Bravo! I like it.
Very nice! Also, now I’m thirsty.
It`s cool =)
You should hit up the Coca-Cola company for some cash for that stylish product placement.
[…] Source Partager : […]
Es genial, me encanta. Dicho lo cual aprovecho para cagarme en los navegadores que no respetan los estándares.
Dang, that’s amazing.
Impresionante, siempre hay algo nuevo que aprender
Очень классная работа, профессионально и качественно. Просто класс!
Галина.
I like this. I am in envy of your mad CSS skills :)
What would make me like it even more is if the Coke Can remained in the same place when the scrollbar is moved.
Sheer genius; I am in awe of your skill, my good sir! Your code is elegant and fantastic … just what we need to teach the World Wide Web to sing! :)
Normalmente no suelo comentar nada, pero te mereces un IMPRESIONANTE. Muy bien.
[…] Román Cortés » Pure CSS Coke Can. […]
[…] Pure CSS Coke Can (tags: via:mento.info) […]
[…] » noticia original […]
pure genius!
WOW! I’m looking at your *one page* of source code and I’m blown away!
I’m not fully understanding how you to this. I looked at the flapping bird and you clearly have separate frames in the same large jpg but I don’t understand how the movement of the scroll bar makes it happen - even worse for the Coke can.
(Y gracias por escribir en castellano y inglés!)
Tio! Eres un crack! Bravo!
your my Hero
ME has roto!!!!
Lovely work. Muy bien, indeed. ;-)
G
Wow! It’s great to see what can be achieved with a bit of ingenuity!
You are likely a CSS genius. Wow. Only reminds me how far I have to go….
Brilliantly Done!!! I think this is really great!
Olé tus cojones
Que llamen a esos q se llaman a si mismos “CSS Gurú”, a ver si son capaces de hacer esto. Si señor, Román, me quito el sombrero.
Achei bem interessante, pena que não funciona no IE 6. E no brasil o IE 6 representa 6% do acesso ao site.
Wow, that’s truly amazing.
(this is not for comments)
Your English translation is a little crude, so I decided to make a more direct English translation for you :)
After creating my previous CSS Paper Bird effect,
I discovered that with the combination of the CSS1 properties background-attachment and background-position, it is possible to create displacement maps,
where using the scroll-bars, these maps can move and apply themselves to different parts of a texture (a background image).
With the displacement maps you can do a wide range of interesting effects, but the complexity of the map directly impacts the HTML and CSS size.
Choosing a appropriate example without a massive size took me some time. After thinking about wave reflections, underwater distortions, magnifying glass effects, a rotating Earth… but then I found the best example, right in front of me on the table: a can of Coca-Cola (my favorite drink).
Due the cylindrical shape of a can, the displacement map is very simple with the parallel projection I did and needed very little code - below 5kb - and will be easy to understand (I hope).
Even if this effect is mainly CSS1 with some bits of CSS2 - for the scrolling div, overflow: auto property -, it is not going to work in IE6, because it doesn’t support background-attachment: fixed. I’ve tested it and it works in IE8, Firefox 3.5, Chrome 3, Safari 4 and Opera 10. Also, the code validates.
Apuntate una, genial!
as a response for your super awesome 3D CAN, I recreated your thing:
http://timo.geekcavecreations.com/pepsi/
I bet that soon CSS is going to be very 3D.
[…] Cortés is having a lot of fun with CSS tricks these days. He just built an example rolling CSS coke can that uses background-attachment, background-position, and a few other tricks to get the effect. No […]
[…] gespeicherte Links:Heavy Metal soll offizielle Religion in UK werden – Nerdcore –Román Cortés » Pure CSS Coke Can –Anonymous Pro –Facebook für Musiker und Bands | myoon –Facebook für […]
[…] Cortés presenta un nuevo ejemplo de uso de CSS con el que simula la rotación de una lata de […]
That is very clever. It will be interesting to see how this concept is adapted and applied elsewhere.
Agradable y útil. Si solamente tuviera más tiempo para aplicarlo :)
WOW brilliant. Can’t believe it created by using just CSS
[…] Shared Pure CSS new 3D effect. […]
[…] Web 2.0 | Дата: 27 Янв 2010 Роман Кортез продемонстрировал интересный CSS трюк, он сделал на чистом CSS 3D банку колы […]
This is really impressive. CSS seems to be a neverending source of new tricks.
Brilliant! Absolutely great idea!
…The can should be rolling the other way though ;P
Stunning. Would never have imagined this could be done in CSS. Very impressive!
[…] 27th January 2010 Very impressive Pure CSS Coke Can from Román Cortés.The Newspaper Club help people make their own newspapers.An ad taken out by […]
This is very freaking cool. This is why I love CSS, always something new it can do.
Impressive work!
Simply awesome… Still can’t believe that this sort of this is possible using CSS.
Thanks for reminding us that CSS hasn’t fully been conquered yet.
[…] última ha sido esta Coca Cola CSS, partiendo de otro anterior basado en el mismo principio, que mediante el desplazamiento del scroll […]
This is hands down the most amazing CSS proof of concept I’ve seen in a long time.
Cool. Now turn it upside down!
Muy bueno el efecto. Además parece que de verdad hay una distorsión por la curvatura de la lata al combinar con el movimiento de ésta. El efecto es impresionante.
Increible, sin palabras
Wooowwww..it’s awesome..
how can you do that?
fies!
amazing!!
It is so cool.
How can you do that? I can’t understand it!
please tell us how to do!!
Incredible Stuff you make with CSS. Respect!
[…] Román Cortés is having a lot of fun with CSS tricks these days. He just built an example rolling CSS coke can that uses background-attachment, background-position, and a few other tricks to get the effect. No […]
[…] Pure CSS Coke CanHey that is clever. Fixed background positioning with a background-clip around it. […]
Just use canvas or svg
And now the vertical one :
http://blog.techno-barje.fr/public/demo/can/can.html
[…] are two versions in the internet. The original is from Roman Cortes (horizontal) and the vertical version is […]
UAUAUAUAUAUAUUAUAUA….. shut up man! amazing!
[…] out how he did them is quite a good test of your understanding of CSS. My favourites are the coke can and the old […]
It would be great if you could adapt this for folded boxes/packaging previews. As a packaging designer, it would be a great way to show packaging in 3D online.
vendela a cocacola latam pa su web
I understand the code behind what you did… but how did you determine the increments to offset each section?
Nada que hacer, muy bueno, como dicen en mi pais: “esta de la p…” jejeje
[…] This little piece of awesomeness by Ramon Cortez has been shooting up the CSS charts since he published it earlier this week and it has inspired me to get my preech on. […]
snyggt!
That’s incredible.
I wish my CSS was that good.
Muy buen efecto, impresionante :D
Buenísimo, Cortez!
WOW! This is RIA.
Hi, Roman
I hope you don’t mind, but I thought it would be fun to make an “impure” version of your CSS Coke Can effect. So, here it is - Impure CSS Coke Can, in 849 bytes. It doesn’t work in IE, and it doesn’t even come close to validating, but it should work in any other modern browser!
http://www.illogicalorder.com/impure-coke/css-coke.html
I made a more readable version that does work in IE and validates, which clocks in at about 1.7 kilobytes.
http://www.illogicalorder.com/impure-coke/
I hope you enjoy them!
so cool
Que demostración de ingenio!! Ya había contemplado las meninas 3D, no paras de impresionar.
very cool
Que bueno sería una explicación sobre como realizar este efecto.
Impresionante, te felicito Hermano DIOS TE CONTINUE BENDICIENDO Suerte…
i am integrating this effect into a site I am developing for a lunch themed website (its perfect), but the tricky part is it is a transparent site, so the white spacing around the can’s png image can’t be there to keep within the design.
I am attempting to resize the can to the entire width of the visible label but cant seem to get it right. any clever ideas on how this can be done on a transparent bg?
Awesome! This is art!
Great work!
Vamos ya!!, si señor, preciosa la sencillez del código…
Wonderful CSS demonstration!
I love it!
太牛了
Impresionante! CSS rulz!
Trop fort. Merci pour le partage
[…] he quedado con la boca abierta al ver un efecto CSS creado por Román Cortés, que simula la rotación de una lata de Coca-Cola sobre sí misma utilizando CSS. Me parece […]
[…] Take a look! […]
Muy interesant
[…] you ever needed an example of the power of CSS, check out this pure CSS coke can. […]
i cant belive in it! its very tricky! nice! congratulation!
[…] Respecto a los diseñadores en sí, no pretendo en este post hacer un debate sobre dónde terminan sus obligaciones para con el “conocimiento”. Admito que me da un poco de vergüenza haber escrito esa frase, me hace querer aprender algo nuevo en los próximos 5 minutos por respeto a la autocapacitación jajaja. Me interesa que vean esta creación en CSS. […]
[…] de él es por una nueva genialidad: El Homero en css, Las meninas en 3D y ahora con la “Pure Css Coke Can“. Aprendan del silencio y del talento de un verdadero […]
simply awesome…
Awesome..
非常漂亮,很欣赏你的创意。
[…] Great: Pure CSS rolling Coke Can […]
[…] Román Cortés » Pure CSS Coke Can. […]
Wow, that’s incredible.
[…] simple in principle, but it is quite impressive to have thought of and implemented it. Check it out here. Román uses multiple divs to create the illusion of an image wrapping around a can by compressing […]
Fantastic…….. congratulations guy!!!!
EXCELENTE!!! Un lujo!!
La verdad, no tengo palabras de felicitaciones por tan maravilloso trabajo… UN GENIO!
Sinceramente, eres mi heroe, por favor sigue mostrando mas de tu magia
[…] Cortés is having a lot of fun with CSS tricks these days. He just built an example rolling CSS coke can that uses background-attachment, background-position, and a few other tricks to get the effect. No […]
Muy muy bueno! ;-)
Simplesmente fantástico. É o que acontece quando nos aprofundamos nas ferramentas.
Parabéns.
Como diriamos en nuestro pais !Brutal! Exito!
[…] How to roll a can using pure CSS by Roman Cortes […]
[…] your CSS thirst with this pure CSS coke can http://www.romancortes.com/blog/pure-css-coke-can/ […]
Muy bueno!!! esta perfecto, te pasaste!
[…] css work http://www.romancortes.com/blog/pure-css-coke-can/ […]
UUUHHLLLL… this is magical.
Nice, man. that’s so beatifull.
[…] man allein mit CSS sehr schöne Scrolleffekte hinbekommt, zeigt Román Cortés. Aus den CSS-Eigenschaften background-attachment und background-position lässt er eine Art […]
[…] Pure CSS Coke Can addthis_url = ‘http%3A%2F%2Fwww.keefermadness.com%2F2010%2F02%2F01%2Fpure-css-coke-can%2F’; addthis_title = ‘Pure+CSS+Coke+Can’; addthis_pub = ”; February 1st, 2010 | Tags: Coke, CSS, Web Browsers | Category: Design […]
[…] CSS Coke Can – http://www.romancortes.com/blog/pure-css-coke-can/ See what you can achieve without even needing the new […]
Realmente impresionou…um efeito sensacional.
Parabéns!
Muito legal o efeito… Dá nem pra acreditar que não tenha JavaScript.
[…] Pure CSS Coke Can […]
[…] Román Cortés » Pure CSS Coke Can Надо покрутить однако. […]
amazing…really looking like a flash.
[…] CSS Coke Can. Pretty […]
Caramba.. great work master of CSS !
[…] http://www.romancortes.com/blog/pure-css-coke-can/ http://anthonycalzadilla.com/css3-ATAT/index.html […]
[…] Enlace | Coca-Cola CSS […]
[…] Pure CSS Coke Can (3D) by a combination of the CSS1 properties background-attachment and background-position, 2D displacement maps could be created and, by scrolling, the displacement map would be applied to different parts of the texture (a background image). (tags: web development programming graphics design webdesign art inspiration html css) […]
Great use of scrolling and CSS. Keep up the good work!
Excelente! Estou impressionado com este efeito!
Genial amigo!!
Wow!!!!!!!!!!!!!!!!!!!!!
[…] Román Cortés » Pure CSS Coke Can (tags: WebDesign CSS CSS3 3D Animation cool Inspiration) […]
[…] Turning Coke Can (Control With Scrollbar) […]
that’s amazing ! thanks
very cool awesome
[…] Lata de Coca-Cola con scroll creada únicamente en CSS! http://www.romancortes.com/blog/pure-css-coke-can/ #css […]
[…] Cortés shows a very nice technical trick on his blog with CSS. You can rotate a coke can by using a scrollbar and he does this without any javascript. […]
Stunning, great work!
Me hize una idea de como puede ser pero sinceramente la primera vez que lo vi me ha sorprendido, felicidades por el esfuerzo. Muy bueno.
Fua, increible el efecto, muy chulo, y por lo que veo, un exitazo de publico y critica! :D
Felicidades!
¡Muy impresionante! Me encantó.
Excellent idea.
I will try and make a product rotator script based on this and a little bit of java to make it move automatically in a loop.
Good work! :)
[…] Pure CSS Coke Can […]
[…] info: CSS Code Can Loading google.load(’search’, ‘1′); google.setOnLoadCallback(function(){ new […]
Супер!!! Молодец…
It is creative.
oooooo////// wow !!!! superb man. Just can’t think in CSS….great job sir.
[…] Pure CSS Coke Can http://www.romancortes.com/blog/pure-css-coke-can/ […]
[…] […]
[…] Rolling a coke can around with pure CSSRomán Cortés is having a lot of fun doing CSS tricks these days. He just built a rolling coke can that uses background-attachment, background-position and a few other tricks to achieve the effect. No fancy CSS3 needed here! […]
[…] Rolling a coke can around with pure CSSRomán Cortés is having a lot of fun doing CSS tricks these days. He just built a rolling coke can that uses background-attachment, background-position and a few other tricks to achieve the effect. No fancy CSS3 needed here! […]
Bloody clever
Extraordinário! Pura criatividade de um vizinho castelhano! :)
Very “cortés” in the way you treated that Ajaxian hacker :)
Hey Roman, do you have the instructions for this available? I only see a very brief summary. I’m curious to learn about how you did this in the form of some type of tutorial. Please help point me in the right direction if you can! Nice looking effect! :)
Wow. Took me a while to understand how this works.. Use Firebug to add “border:1px solid red;” to the tag, which makes it a clearer if you’re a bit slow like me :)
Cool Man Very Good… :)
[…] roll the can go to: http://www.romancortes.com/blog/pure-css-coke-can/ If you have internet explorer 6 and can not view the can, maybe you could scrounge around the […]
[…] Rolling a coke can around with pure CSS Román Cortés is having a lot of fun doing CSS tricks these days. He just built a rolling coke can that uses background-attachment, background-position and a few other tricks to achieve the effect. No fancy CSS3 needed here! […]
[…] la lista, mi animación preferida es la de Roman Cortés con la lata de Coca […]
a-ma-zing work !
[…] Rolling a coke can around with pure CSS Román Cortés is having a lot of fun doing CSS tricks these days. He just built a rolling coke can that uses background-attachment, background-position and a few other tricks to achieve the effect. No fancy CSS3 needed here! […]
[…] Román Cortés » Pure CSS Coke Can (tags: css tricks development) […]
[…] Rolling a coke can around with pure CSSRomán Cortés is having a lot of fun doing CSS tricks these days. He just built a rolling coke can that uses background-attachment, background-position and a few other tricks to achieve the effect. No fancy CSS3 needed here! […]
Kinda cool! ;)
[…] Rolling a coke can around with pure CSSRomán Cortés is having a lot of fun doing CSS tricks these days. He just built a rolling coke can that uses background-attachment, background-position and a few other tricks to achieve the effect. No fancy CSS3 needed here! […]
[…] Check it out at http://www.romancortes.com/blog/pure-css-coke-can/ […]
it’s Nice :)
[…] 12. Turning Coke Can (Control With Scrollbar) […]
[…] turning coke can (control with scrollbar) – tutorial (scrollbar etkisiyle döndürme) […]
[…] Oh, this is so cool, a coke can, which rolls when you scroll and all that with pure CSS: http://www.romancortes.com/blog/pure-css-coke-can/ […]
[…] Rolling a coke can around with pure CSS Román Cortés is having a lot of fun doing CSS tricks these days. He just built a rolling coke can that uses background-attachment, background-position and a few other tricks to achieve the effect. No fancy CSS3 needed here! […]
I m spell bounded by your work… Keep it up :)
fantastic!
This is incredible! You are doing wonderful things. Keep pushing the envelope - and sharing your incredible results with us.
[…] 12. Turning Coke Can (Control With Scrollbar) […]
[…] 12. Turning Coke Can (Control With Scrollbar) […]
[…] 12. Turning Coke Can (Control With Scrollbar) […]
hey Great!! but when i am scrolling then i cant see COKE’s brand Please some 1 help me give Full Code HELP Pls