I have a site layout I'm working on that has a main content area and then at each of the four corners of the content area sits a corner graphic. The overall effect is that of a desk blotter.
Here is the code for my top left hand corner:
.corner-top-left { width:96px ; height:96px ; background:url("images/corner.png") no-repeat ; position:absolute ; top:-5px ; left:-5px ; z-index:3000 ; }
Rather than make four individual corner images, what I would like to do (if possible) is use the original image (corner.png) and rotate it using CSS.
Is there a cross browser compatible way to do this?
Many thanks!
css file, stylesheet, or <style> tags, you can use the CSS class name in any of your image tags. To rotate an image by another measure of degrees, change the "180" in the CSS code and <img> tag to the degree you desire.
We can add the following to a particular tag in CSS: -webkit-transform: rotate(90deg); -moz-transform: rotate(90deg); -o-transform: rotate(90deg); -ms-transform: rotate(90deg); transform: rotate(90deg); In case of half rotation change 90 to 45 .
transform: rotate(angle); The value “angle” represents the number of degrees the element should rotate. You can specify a rotate that is clockwise using a positive degree number (i.e. 45). Or, you can rotate in the opposite direction using a negative degree value (i.e. -39).
http://jsfiddle.net/tJkgP/2/
CSS to rotate by 45 degrees:
.desk { width: 50%; height: 400px; margin: 5em auto; border: solid 1px #000; overflow: visible; } .desk img { behavior:url(-ms-transform.htc); /* Firefox */ -moz-transform:rotate(45deg); /* Safari and Chrome */ -webkit-transform:rotate(45deg); /* Opera */ -o-transform:rotate(45deg); /* IE9 */ -ms-transform:rotate(45deg); /* IE6,IE7 */ filter: progid:DXImageTransform.Microsoft.Matrix(sizingMethod='auto expand', M11=0.7071067811865476, M12=-0.7071067811865475, M21=0.7071067811865475, M22=0.7071067811865476); /* IE8 */ -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand', M11=0.7071067811865476, M12=-0.7071067811865475, M21=0.7071067811865475, M22=0.7071067811865476)"; }
IE6-8 CSS came from here: CSS rotate property in IE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With