[英]jQuery, shrink div width from left to right
As you can see there is a slide to the left and the with decreases from 100% to 0 at the same time. 如您所见,左侧有一张幻灯片,且同时从100%减少到0。
I want to get this same effect but from left to right. 我想获得相同的效果,但是从左到右。
I can't get it right! 我做错了!
jQuery('#target').animate({ width: '0', left: '-25%' }, 1500, 'swing');
Example Fiddle: http://jsfiddle.net/RsBNk/ 小提琴示例: http : //jsfiddle.net/RsBNk/
That is pretty simple. 那很简单。 Align the image to the right and then decrease it by 25% using jQuery like below: 将图像向右对齐,然后使用jQuery将其降低25%,如下所示:
jQuery: jQuery的:
jQuery('#target').animate({ width: '0', right: '-25%' }, 1500, 'swing');
CSS: CSS:
.box {
width: 100%;
position: absolute;
top: 0;
right: 0; /* Modified this line */
height: 200px;
background-image: url('http://images.icnetwork.co.uk/upl/uxbridgegazette/jul2012/0/4/marc-mccarroll-image-2-304314157.jpg');
background-position: right; /* EDIT: This property needs to be set */
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.