简体   繁体   English

从右到左淡入淡出

[英]fade in and out from right to left

I am trying to fadeIn from left to right and right to left to make something like this: 我试图从左到右,从右到左淡入淡出,使像这样的事情:

在此处输入图片说明

this is my code, but this doesn't work: 这是我的代码,但这不起作用:

$(lastSlide).animate({ width: 'toggle', height:'340', opacity: 'toggle' }, "slow");

this is what I get: 这就是我得到的:

在此处输入图片说明

The problem is that you get the distortion by reducing the width of the image. 问题在于您会通过减小图像的宽度来获得失真。 Try to wrap the image in the div: 尝试将图像包装在div中:

<div id="main">
  <div id="img1">
    <img src="..."/>
  </div>
  <div id="img2">
    <img src="..."/>
  </div>
 </div>

 $("#img2").animate({ width: 'toggle', height:'340', opacity: 'toggle' }, "slow");

Simple example: https://jsfiddle.net/12x4cauv/ 简单示例: https//jsfiddle.net/12x4cauv/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM