简体   繁体   English

猫头鹰轮播:图像高度问题

[英]OWL CAROUSEL : image height issue

Hello StackOverflow community. 您好StackOverflow社区。

In my new Java EE project I decided to use Owl Carousel, a powerful, flexible, and easy to use plugin to display some available gifts to win. 在我的新Java EE项目中,我决定使用Owl Carousel,它是一个功能强大,灵活且易于使用的插件,可以显示一些可用的礼物以赢得胜利。

I noticed some unwanted behaviour regarding the customization of the images height. 我注意到一些有关图像高度自定义的不良行为。

Here is an image of the page using owl carousel but without customization of the height of images : 这是使用猫头鹰轮播的页面图像,但未自定义图像高度: 在此处输入图片说明

Here is an image of the page using owl carousel with customization of the height of images : 这是使用猫头鹰轮播的页面图像,其中图像高度自定义:

在此处输入图片说明

here is the code i'm using ti generate the carousel : 这是我正在使用ti生成轮播的代码:

 $(document).ready(function() { var owl = $("#owl-demo"); owl.owlCarousel({ items: 6, //10 items above 1000px browser width itemsDesktop: [1199, 4], //5 items between 1000px and 901px itemsDesktopSmall: [979, 3], // betweem 900px and 601px itemsTablet: [600, 2], //2 items between 600 and 0 itemsMobile: [479, 1] // itemsMobile disabled - inherit from itemsTablet option }); // Custom Navigation Events $(".next").click(function() { owl.trigger('owl.next'); }) $(".prev").click(function() { owl.trigger('owl.prev'); }) $(".play").click(function() { owl.trigger('owl.play', 1000); //owl.play event accept autoPlay speed as second parameter }) $(".stop").click(function() { owl.trigger('owl.stop'); }) }); 
 .img { display: inline-block; max-width: 100%; height: 130px; /* the problem (if you remove it, the carousel works !!!! )*/ margin-bottom: 30px; } #owl-demo .item { color: #FFF; height: 250px; text-align: center; border: 1px solid rgb(228, 228, 228); border-radius: 0.6em; margin: 3px; background: #93C572; } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/owl-carousel/1.3.3/owl.carousel.js"></script> <div class="row"> <h4 style="text-align: center;">Cadeaux À Votre Portée</h4> <div class="customNavigation"> <img src="http://placehold.it/500" style="margin-right: 20px;" /><a class="btn prev">&lt;</a> <a class="btn next">&gt;</a> <img src="http://placehold.it/500" style="margin-left: 20px;" /> </div> </div> <div class="row"> <div id="owl-demo" class="owl-carousel owl-theme"> <p:panel styleClass="item"> <div class="row"> <p:graphicImage styleClass="img" library="espace" name="http://placehold.it/500" /> </div> <div class="row">Lorem Ipsum</div> <div class="row"> <p:commandButton icon="fa fa-shopping-cart" /> </div> <div class="row">1700 PTs</div> </p:panel> <p:panel styleClass="item"> <div class="row"> <p:graphicImage styleClass="img" library="espace" name="http://placehold.it/500" /> </div> <div class="row">Lorem Ipsum</div> <div class="row"> <p:commandButton icon="fa fa-shopping-cart" /> </div> <div class="row">1250 PTs</div> </p:panel> <p:panel styleClass="item"> <div class="row"> <p:graphicImage styleClass="img" library="espace" name="http://placehold.it/500" /> </div> <div class="row">Lorem Ipsum</div> <div class="row"> <p:commandButton icon="fa fa-shopping-cart" /> </div> <div class="row">900 PTs</div> </p:panel> <p:panel styleClass="item"> <div class="row"> <p:graphicImage styleClass="img" library="espace" name="http://placehold.it/500" /> </div> <div class="row">Lorem Ipsum</div> <div class="row"> <p:commandButton icon="fa fa-shopping-cart" /> </div> <div class="row">1300 PTs</div> </p:panel> <p:panel styleClass="item"> <div class="row"> <p:graphicImage styleClass="img" library="espace" name="http://placehold.it/500" /> </div> <div class="row">Lorem Ipsum</div> <div class="row"> <p:commandButton icon="fa fa-shopping-cart" /> </div> <div class="row">3000 PTs</div> </p:panel> <p:panel styleClass="item"> <div class="row"> <p:graphicImage styleClass="img" library="espace" name="http://placehold.it/500" /> </div> <div class="row">Lorem Ipsum</div> <div class="row"> <p:commandButton icon="fa fa-shopping-cart" /> </div> <div class="row">1500 PTs</div> </p:panel> <p:panel styleClass="item"> <div class="row"> <p:graphicImage styleClass="img" library="espace" name="http://placehold.it/500" /> </div> <div class="row">Lorem Ipsum</div> <div class="row"> <p:commandButton icon="fa fa-shopping-cart" /> </div> <div class="row">900 PTs</div> </p:panel> <p:panel styleClass="item"> <div class="row"> <p:graphicImage styleClass="img" library="espace" name="http://placehold.it/500" /> </div> <div class="row">Lorem Ipsum</div> <div class="row"> <p:commandButton icon="fa fa-shopping-cart" /> </div> <div class="row">1300 PTs</div> </p:panel> <p:panel styleClass="item"> <div class="row"> <p:graphicImage styleClass="img" library="espace" name="http://placehold.it/500" /> </div> <div class="row">Lorem Ipsum</div> <div class="row"> <p:commandButton icon="fa fa-shopping-cart" /> </div> <div class="row">1300 PTs</div> </p:panel> <p:panel styleClass="item"> <div class="row"> <p:graphicImage styleClass="img" library="espace" name="http://placehold.it/500" /> </div> <div class="row">Lorem Ipsum</div> <div class="row"> <p:commandButton icon="fa fa-shopping-cart" /> </div> <div class="row">1300 PTs</div> </p:panel> <p:panel styleClass="item"> <div class="row"> <p:graphicImage styleClass="img" library="espace" name="http://placehold.it/500" /> </div> <div class="row">Lorem Ipsum</div> <div class="row"> <p:commandButton icon="fa fa-shopping-cart" /> </div> <div class="row">1300 PTs</div> </p:panel> </div> </div> 

---EDITED--- -编辑-

May be I wasn't very clear about what is the problem : 可能是我对问题不是很清楚:

  • If I don't edit the height of the images inside the carousel it works fine like in the first image. 如果我不编辑转盘内图像的高度,则可以像第一个图像一样正常工作。 (CSS is in a separate file) (CSS在单独的文件中)
  • If I try to edit the height of the images inside the carousel the page becomes blank like in the second image. 如果我尝试编辑轮播中图像的高度,则该页面将像第二幅图像一样变为空白。 (CSS is in a separate file) (CSS在单独的文件中)

I'm not very familiar with jQuery and JavaScript so I don't understand what is the reason of this behaviour. 我对jQuery和JavaScript不太熟悉,所以我不理解这种行为的原因是什么。

----EDITED 2---- ----编辑2 ----

THIS PROBLEM IS PRESENT ONLY IN GOOGLE CHROME , NOT IN INTERNET EXPLORER AND NOT IN MOZILLA FIREFOX . 这个问题仅存在于Google Chrom上不在 Internet ExplorerMOZILLA FIREFOX中

I solved the problem by just updating the height of the images from 130px to 135px , i just found this solution randomly but still i don't understand the reason behind the problem or the solution. 我刚好从更新的130px图像的高度135px解决了这个问题,我刚刚发现这个解决方案随机但我仍然不明白的问题或解决方案背后的原因。

Old CSS code : 旧的CSS代码:

.img {  display: inline-block;  max-width: 100%;  height: 130px;    margin-bottom: 30px; }

New CSS code : 新的CSS代码:

.img {  display: inline-block;  max-width: 100%;  height: *135px*;  margin-bottom: 30px;}

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

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