Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I have a image with dimension 15152 * 404. I just want to show that img in div. But that image need to change horizontally(when its changed automatically, that img person doing some action like gif) by css or jquery. I have tried the following html, Img shown correctly but need to move horizontally. Please help me for this.

FOR IMG : jasper.png[^]

What I have tried:

HTML :

HTML
<!DOCTYPE html>


div.picture1 {
   background-image:url('jasper.png');  
   transform-origin: 0px 0px 0px; 
   z-index: 82; 
   transform: translate(250px, 0);
   width: 200px; 
   height: 404px;    
   margin: 0 auto;    
   padding: 0;
}
&lt;/style

<body>

<div class="picture1"></div>

</body>
</html>
Posted
Updated 7-Apr-17 18:33pm
v3
Comments
ZurdoDev 4-Apr-17 9:11am    
Change how? And when?
SnvMohan 5-Apr-17 0:07am    
Change means, showing first person on that div, and changed into next person and next and next in milliseconds(5 milliseconds), When its happen that person look like doing something just like GIF.. Always its need to change showing person in that image
ZurdoDev 5-Apr-17 7:11am    
It looks like you are setting the background image of the div. So, where are you stuck? Do you know how to change the background image?
SnvMohan 8-Apr-17 0:34am    
I have found the solution.. Thanks for your time

1 solution

I have try the following.. Its working

<!DOCTYPE html>

<meta http-equiv="X-UA-Compatible" content="IE=9">


<canvas id="icanvas" width="200px" height="404px">


var imgTag = new Image();
imgTag.src = "https://d27jyp35i1l6s7.cloudfront.net/v3.2/agni/assets/carousel/classic/new-classic/kimberly.png";
var canvas = document.getElementById('icanvas');
var ctx = canvas.getContext("2d");
ctx.drawImage(imgTag, 0, 0);
var lsFrameWidth = -202.0;
var lsWidth = 0;
timesRun = 1;
var interval = setInterval(function(){
if(timesRun === 75){
timesRun = 1;
lsWidth = 0;
}else if(timesRun &lt; 75)
{
timesRun = timesRun + 1;
ctx.clearRect(0, 0, canvas.width, canvas.height)
ctx.drawImage(imgTag, lsWidth, 0);
lsWidth = lsWidth + (lsFrameWidth);
}
}, 90);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900