0

Hi i want to rotate the image by 90 deg and align the image inside the div borders. ie the outer div should expand automatically depending upon the height of the image. I have attached the JSFIDDLE with this.

<div style="float:left;border:1px solid #000;">
    <span style="float:left;transform:rotate(90deg); transform:50% 50% 0;">
        <img src="http://dimox.net/wp-images/css-border-radius.jpg"/>
    </span>
</div>
mpen
  • 272,448
  • 266
  • 850
  • 1,236
OCJP
  • 1,033
  • 1
  • 10
  • 17

2 Answers2

0

You can use CSS3 to rotate the element 90deg (on modern browsers) - if you want to move the div as well you can apply the rotate to the div itself:

div img {
    -moz-transform: rotate(90deg) translateX(150px);
    -webkit-transform: rotate(90deg) translateX(150px);
    -o-transform: rotate(90deg) translateX(150px);
    -ms-transform: rotate(90deg) translateX(150px);
    transform: rotate(90deg) translateX(150px);
}

http://jsfiddle.net/L7pNa/3/

Or if you just want it to have a border - you can use a box shadow for that instead and remove the div markup.

jamki
  • 51
  • 4
  • i dont need border i want it to be inside div.for understanding i added border. – OCJP Jun 06 '14 at 16:49
  • So rotating it will cause the image to display off the page - so I've added the transform property to the img element. – jamki Jun 06 '14 at 16:54
0

please try this code.

<div style="float:left;border:1px solid #000;overflow: auto;">
    <span style="float:left; -ms-transform: rotate(90deg); /* IE 9 */     -webkit-transform: rotate(90deg); /* Chrome, Safari, Opera */     transform: rotate(90deg);">
        <img src="http://dimox.net/wp-images/css-border-radius.jpg">
    </span>
</div>