tags:

views:

2193

answers:

7
+8  A: 

CCS 3 will offer this possibility, but it's still not cross-browser and you cannot do it with traditional HTML + CSS... yet.

Websites having a tilted image do it by rotating it in, say, Photoshop and making its background transparent. That's the whole trick there's to it.

Tip: save that picture to your HD and see by yourself. That's probably just an squared image with transparent background, or maybe it has the current background cut nicely to fit there.

Seb
+1  A: 

To my knowledge you can not do that. Are you sure the image you are thinking of isn't tilted in Photoshop or similar and just added to the page like that?

Egil Hansen
+1  A: 

No. You can't.

Tilting images and text is still JavaScript juju.

Jekke
-1: So, when did JavaScript gain this ability?
Chris Lively
I assumed that it was a "pre-tilted in photoshop" deal, but I never knew that JS *couldn't* do this...can it not?
David Thomas
Javascript can. Take a look at instant.js: http://www.netzgesta.de/instant/
Jekke
no kidding... it really can!
Michelle Lee
Apple introduced the <canvas> tag for their dashboard widgets, dropped it in Safari later, and then Gecko picked it up. It's part of the HTML 5 spec. That's how the transformations work.
rpflo
+1  A: 

You can use Apple specific CSS attributes (soon to be ratified, and then they'll remove the webkit prefixes for them) to do this and animation effects, but it will only show up in Safari and Chrome right now. Still, they look quite pretty and CSS is simple to do.

Right now it's probably just done in Photoshop, and nicely anti-aliased there as well, so that it has a consistent cross-browser appearance.

JeeBee
+7  A: 

You can do it, but only in Firefox 3.5+ and Safari 3.2+ (and recent webkit based browsers). Both provide browser specific CSS extensions for skew: -moz-transform and -webkit-transform respectively.

Here's a nice example that builds a 3d looking cube out of divs: (from http://www.fofronline.com/2009-04/3d-cube-using-css-transformations/)

<div class="cube">
        <div class="topFace">
                <div>
                        Content
                </div>
        </div>
        <div class="leftFace">
                Content
        </div>
        <div class="rightFace">
                Content
        </div>
</div>

And CSS:

.cube {
        position: relative;
        top: 200px;
}

.rightFace,
.leftFace,
.topFace div {
        padding: 10px;
        width: 180px;
        height: 180px;
}

.rightFace,
.leftFace,
.topFace {
        position: absolute;
}
.leftFace {
        -webkit-transform: skewY(30deg);
        -moz-transform: skewY(30deg);
        background-color: #ccc;
}

.rightFace {
        -webkit-transform: skewY(-30deg);
        -moz-transform: skewY(-30deg);
        background-color: #ddd;
        left: 200px;
}
MrKurt
+1  A: 

We are doing something similar at work, we have to do it on the fly.

You can't do it with just html/css, however we are using an image library through a php script to generate them automatically, and then make the background transparent.

jskulski
you don't generate the image every time but either cache it or store in on your server or DB so that you use so much CPU power every time?
Michelle Lee
+1  A: 

Use a PHP GD Library. Makes things so much easier.

James Brooks