简体   繁体   English

我怎样才能使jquery.css不动画,而立即进行更改?

[英]How can I make jquery.css not animate and instead do the changes instantly?

Everything below is tested in Chrome, on OSX. 下面的所有内容均已在OSX的Chrome中进行了测试。

Take a look at the main image at this website I'm building: http://www.appsbayou.se 看一下我正在建立的这个网站上的主要图像: http : //www.appsbayou.se

As you can see when you load the page, the image looks like it's "sliding" to it's correct position. 正如您在加载页面时所看到的,图像看起来像是在“滑动”到正确的位置。 I don't want this behaviour. 我不要这种行为。

The code behind this page is from a custom wordpress theme and in this matter I have no say. 该页面后面的代码来自自定义的wordpress主题,在这个问题上我没有发言权。 My only job is to "fix the image so it doesn't do an animation". 我唯一的工作就是“修复图像,使其不做动画”。

In the source code I've found that these lines are the culprit: 在源代码中,我发现这些行是罪魁祸首:

$(this).css("width", new_img_width);
$(this).css("max-width", new_img_width);

where $(this) refers to the <img> tag. 其中$(this)引用<img>标记。 There is no .animate() here. 这里没有.animate()。 Then why is a simple changing of width/maxwidth with jQuery doing so with an animation and how can I make those lines instant instead? 那么,为什么用jQuery通过动画来简单地更改width / maxwidth呢?我该如何使这些行立即变为呢?

remove 去掉

img {
transition: width 0.5s ease-in-out 0s, 
            left 0.7s ease-in-out 0s,
             right 0.7s ease-in-out 0s;
}  

from

http://www.appsbayou.se/wp-content/themes/customizr/inc/assets/css/orange.min.css?ver=3.1.24 http://www.appsbayou.se/wp-content/themes/customizr/inc/assets/css/orange.min.css?ver=3.1.24

at line 15 在第15行

If you do an "Inspect Element" on the image, you'll see it is contained in a set of div s that employ a carousel scheme. 如果在图像上执行“检查元素”,则会看到该元素包含在采用轮播方案的div集合中。 There are several things you can do. 您可以做几件事。 One is to edit the page HTML and get rid of the container divs. 一种是编辑页面HTML并摆脱容器div。 That may have some unwanted side effects though with respect to formatting. 尽管在格式化方面,这可能会产生一些不必要的副作用。

Another option may be to iterate up the parent chain of $(this) and start selectively removing classes from containing divs. 另一个选择可能是迭代$(this)的父链,并开始选择性地从包含div的类中删除类。 For example get rid of the center-slides-enabled class and see what happens. 例如,摆脱center-slides-enabled类,然后看看会发生什么。 Without knowing more about the structure of the carousel (you're using minified Javascript wrappers so it's sort of hard to know what's going on) I can't say exactly what the right class to get rid of is, but with some trial-and-error I think you should be able to figure out pretty rapidly what you need to do. 在不了解轮播的更多信息的情况下(您正在使用缩小的Javascript包装器,因此很难知道发生了什么)我无法确切地说说要删除的正确类是什么,但是要进行一些尝试,然后-error我认为您应该能够很快弄清楚您需要做什么。

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

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