简体   繁体   English

在带有Respond.js的IE8中使用Owl Carousel

[英]Using Owl Carousel in IE8 with Respond.js

I can't seem to get Owl Carousel to work in IE8 when I add respond.js. 当我添加response.js时,我似乎无法让Owl Carousel在IE8中工作。 Has anyone else been able to do this? 还有其他人能够做到这一点吗? I don't even know where to start troubleshooting. 我什至不知道从哪里开始进行故障排除。

The jQuery carousel plugin I'm referring to is: http://owlgraphic.com/owlcarousel/ 我指的jQuery旋转木马插件是: http : //owlgraphic.com/owlcarousel/

I know this question is a bit old but I had an issue with IE8 and Owl Carousel today (hopefully this is a similar issue) and thought maybe this could help someone in the future. 我知道这个问题有点老,但是我今天遇到了IE8和Owl Carousel的问题(希望这是一个类似的问题),并认为这可能会在将来对某人有所帮助。

Problem: As the page would render items in several carousels I had set up the items would overflow outside of the carousel container. 问题:因为页面会在多个转盘中渲染项目,所以我设置的项目会在转盘容器之外溢出。 As soon as I would resize the page everything would then render into it's correct position and size. 一旦我调整页面的大小,所有内容就会呈现为正确的位置和大小。 This can be caused by .resize() which can cause issues with IE. 这可能是由.resize()引起的,它可能导致IE问题。

Solution: I ran respond.js along side an ie.css file inside of an IE conditional. 解决方案:我在IE条件内的ie.css文件旁边运行了response.js。 I also run html5shiv as well inside the conditional. 我也有条件地运行html5shiv。

<!--[if lt IE 9]>
    <link href="css/ie.css" rel="stylesheet" type="text/css"/>
    <script src="js/html5shiv.js"></script>
    <script src="js/respond.min.js"></script>
    <![endif]-->

Then in my css I would give a fixed width to each carousel ID. 然后在css中,为每个轮播ID指定固定宽度。 If you look at the demo owl carousel (I couldn't do the body [which works as well] because I had background colors that were full-width): 如果您看一下演示猫头鹰轮播(我无法做到这一点(效果很好),因为我的背景色是全角的):

<div id="owl-example" class="owl-carousel">
<div> Your Content </div>
<div> Your Content </div>
  ...
</div>

And in my ie.css file I just set a width to that ID 在我的ie.css文件中,我只是为该ID设置了宽度

#owl-example{width: 1024px;}

After doing that my page would render correctly and Owl Carousel would work properly. 完成该操作后,我的页面将正确呈现,Owl Carousel将正常工作。 Like was mentioned in the comments above by Adam, if someone is using IE8 they probably don't know what responsive is, so my feeling is setting a width should be satisfactory for users and you can always muscle in IE8 since respond.js is working with media queries at desired break points. 就像亚当在上面的评论中提到的那样,如果有人使用IE8,他们可能不知道响应是什么,所以我的感觉是设置宽度对于用户来说应该是令人满意的,并且您可以始终使用IE8,因为response.js可以正常工作在所需的断点处进行媒体查询。 Hopefully this helps. 希望这会有所帮助。

I had similar issue. 我有类似的问题。 Owl Carousel has a build-in data method "reinit". Owl Carousel具有内置数据方法“ reinit”。 I just reinitialized Owl carousel after all content has been loaded. 加载完所有内容后,我只是重新初始化了Owl轮播。 But it needed some delay (I don't know way :s). 但这需要一些延迟(我不知道:s的方式)。 But this solution worked for me. 但是这个解决方案对我有用。

var owl = $("#owl-wrap").data('owlCarousel');

if( $('html').hasClass('no-backgroundsize') )
{
  $(window).load(function() {
    window.setTimeout(function() {
      owl.reinit();
    }, 250);
  });
}

The class name "no-backgroundsize" comes from Modernizr. 类名“ no-backgroundsize”来自Modernizr。 Because IE8 doesn't support background-sizing, I thought that it would be good way to detect IE8. 因为IE8不支持后台调整大小,所以我认为这是检测IE8的好方法。

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

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