0

I want to make my original image to portrait when I mouse over on an image. Can anyone please tell me how to do this? I want to open whole image on mouseover with portrait effect.

halfer
  • 19,824
  • 17
  • 99
  • 186

4 Answers4

1

You should use css transform.

.main:hover img {
    -webkit-transform: rotate(90deg);
    -moz-transform: rotate(90deg);
    -o-transform: rotate(90deg);
    -ms-transform: rotate(90deg);
    transform: rotate(90deg);
}

example jsfiddle here

Bhavesh G
  • 3,000
  • 4
  • 39
  • 66
1

You should use jQuery to this with method mouseover() and mouseout(), The rotate attribute doesn't let your picture horizontally. Here my JSfiddle.

http://jsfiddle.net/gLj8n9s6/

CSS

#main {
    width: 300px;
    height: 200px;
    overflow: hidden;
}
#img {
    width:300px;
    height:200px;
}

HTML

<div id="main">
    <img id="img" src="http://s13.postimg.org/m3yqyd7zb/windows_xp_bliss_wide.jpg" />
</div>

jQuery

$('#main').mouseover(function() {
    $(this).animate({width : '200px'});
});
$('#main').mouseout(function() {
    $(this).animate({width : '300px'});
});

Or KISS by doing this in pure CSS without the animate method in jQuery

KeizerBridge
  • 2,707
  • 7
  • 24
  • 37
0

On mouse over of the image you can open a DIV with some z-index and then place the image and do some css styling to make that portrait effect. You can make the popup DIV size as per the image size as well. Check this for css property. I think this will help you.

Deepak Biswal
  • 4,280
  • 2
  • 20
  • 37
0

This is pretty straight forward using css3

img:hover {
 transform: rotate(90deg);
}

have a look at css transform http://www.w3schools.com/css/css3_2dtransforms.asp

edit : actually that might not be what you want. The image would transform back to landscape on mouseout

Dionys
  • 3,083
  • 1
  • 19
  • 28