html – Safari图像重叠问题

前端之家收集整理的这篇文章主要介绍了html – Safari图像重叠问题前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
与Safari有一个奇怪的CSS图像问题,并且无法在任何地方找到任何有关此在线的信息.

每件首饰都有一个小缩略图.如果有更多的缩略图可以容纳在那个空间中,我设置JS让它们通过调整外部div的左边缘来回滑动(很像smoothdivscroll,但不是那么复杂).

在Safari中由于某种原因,小缩略图库中的第一个图像保持静态,而其他图像在其上滚动.看起来很废话.我无法理解为什么.它可能是Safari中的一个错误吗?

我觉得这是一个CSS问题,因为在添加这个滑动功能之前,我们只限制了5个图像,并且它们会在Safari中加载重叠和失真……

http://jeandousset.com/jewellery/engagement-rings/

示例HTML:

  1. <div class="span12 offset6 product-images-container" style="margin-left: 140px;">
  2. <div class="product-zoom-container">
  3. <img id="eva-main-image" class="main-image" src="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-round-cut-diamond-front.jpg" data-post-id="530" title="eva-engagement-ring-cushion-cut-diamond-angle-" alt="">
  4. </div>
  5.  
  6. <div id="eva-gallery" class="product-gallery text-center">
  7. <div class="scroll-products-right"></div>
  8. <div class="scroll-products-left"></div>
  9. <div class="scrollable-area">
  10. <div class="product-gallery-inner" style="width: 420px; margin-left: -30px;">
  11.  
  12. <a href="#" class="product-thumbnail" data-image="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-cushion-cut-diamond-angle-.jpg" data-post-id="530">
  13. <img src="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-cushion-cut-diamond-angle-.jpg" title="eva-engagement-ring-cushion-cut-diamond-angle-" alt="">
  14. </a>
  15. <a href="#" class="product-thumbnail" data-image="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-cushion-cut-diamond-under.jpg" data-post-id="530">
  16. <img src="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-cushion-cut-diamond-under.jpg" title="eva-engagement-ring-cushion-cut-diamond-under" alt="">
  17. </a>
  18. <a href="#" class="product-thumbnail" data-image="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-cushion-cut-diamond-angle.jpg" data-post-id="530">
  19. <img src="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-cushion-cut-diamond-angle.jpg" title="eva-engagement-ring-cushion-cut-diamond-angle" alt=""></a>
  20. <a href="#" class="product-thumbnail active" data-image="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-round-cut-diamond-front.jpg" data-post-id="530">
  21. <img src="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-round-cut-diamond-front.jpg" title="eva-engagement-ring-round-cut-diamond-front" alt="">
  22. </a>
  23. <a href="#" class="product-thumbnail" data-image="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-cushion-cut-diamond-turned-profile.jpg" data-post-id="530">
  24. <img src="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-cushion-cut-diamond-turned-profile.jpg" title="eva-engagement-ring-cushion-cut-diamond-turned-profile" alt="">
  25. </a>
  26. <a href="#" class="product-thumbnail" data-image="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-asscher-cut-diamond-angle.jpg" data-post-id="530">
  27. <img src="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-asscher-cut-diamond-angle.jpg" title="eva-engagement-ring-asscher-cut-diamond-angle" alt="">
  28. </a>
  29. <a href="#" class="product-thumbnail" data-image="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-asscher-cut-diamond-angle.jpg" data-post-id="530">
  30. <img src="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-asscher-cut-diamond-angle.jpg" title="eva-engagement-ring-asscher-cut-diamond-angle" alt="">
  31. </a>
  32. <a href="#" class="product-thumbnail" data-image="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-asscher-cut-diamond-angle.jpg" data-post-id="530">
  33. <img src="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-asscher-cut-diamond-angle.jpg" title="eva-engagement-ring-asscher-cut-diamond-angle" alt="">
  34. </a>
  35. <a href="#" class="product-thumbnail" data-image="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-asscher-cut-diamond-angle.jpg" data-post-id="530">
  36. <img src="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-asscher-cut-diamond-angle.jpg" title="eva-engagement-ring-asscher-cut-diamond-angle" alt="">
  37. </a>
  38.  
  39.  
  40. </div>
  41. </div>
  42. </div>

CSS:

  1. .product-gallery {
  2. *zoom: 1;
  3. max-height: 70px;
  4. position: relative;
  5. margin-left: auto;
  6. margin-right: auto;
  7. }
  8. .product-gallery:before,.product-gallery:after {
  9. display: table;
  10. content: "";
  11. line-height: 0;
  12. }
  13. .product-gallery:after {
  14. clear: both
  15. }
  16. .product-gallery .scrollable-area {
  17. overflow: hidden;
  18. position: relative;
  19. margin-left: auto;
  20. margin-right: auto;
  21. width: 85%;
  22. }
  23. .product-gallery .scroll-products-right,.product-gallery .scroll-products-left {
  24. position: absolute;
  25. width: 30px;
  26. height: 100%;
  27. background: url(./../img/arrow-small-left.png) center center no-repeat #fff;
  28. background-color: rgba(255,255,0.6);
  29. top: 0;
  30. left: 0;
  31. z-index: 20;
  32. opacity: .6;
  33. filter: alpha(opacity=60);
  34. }
  35. .product-gallery .scroll-products-right:hover,.product-gallery .scroll-products-left:hover {
  36. cursor: pointer !important;
  37. background-color: rgba(255,0.8);
  38. opacity: 1;
  39. filter: alpha(opacity=100);
  40. }
  41. .product-gallery .scroll-products-right {
  42. right: 0;
  43. left: auto;
  44. background: url(./../img/arrow-small-right.png) center center no-repeat #fff;
  45. background-color: rgba(255,0.6);
  46. }
  47. .product-gallery .product-thumbnail {
  48. float: left;
  49. max-width: 70px;
  50. opacity: .5;
  51. filter: alpha(opacity=50);
  52. }
  53. .product-gallery .product-thumbnail.active {
  54. opacity: 1;
  55. filter: alpha(opacity=100);
  56. }
  57. .product-gallery .product-thumbnail:before,.product-gallery .product-thumbnail:after {
  58. content: ""
  59. }

JS:

  1. Dousset.product = {
  2.  
  3. currentWindowWidthMin: null,currentInterval: null,init: function () {
  4.  
  5. $('#wrapper').on('click','.product-thumbnail',Dousset.product.thumbClicked);
  6.  
  7. // $('.product-thumbnail').css({
  8. // 'float': 'none',// 'display': 'inline-block'
  9. // });
  10.  
  11. $('#wrapper').on('mousedown','.scroll-products-right',Dousset.product.scrollThumbsLeft);
  12. $('#wrapper').on('mousedown','.scroll-products-left',Dousset.product.scrollThumbsRight);
  13. $('#wrapper').on('mouseup','.scroll-products-left,.scroll-products-right',function(e){
  14. clearTimeout(Dousset.product.currentInterval);
  15. Dousset.product.currentInterval = null;
  16. });
  17.  
  18. if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
  19. $('#wrapper').on('click',Dousset.product.scrollThumbsLeftBatch);
  20. $('#wrapper').on('click',Dousset.product.scrollThumbsRightBatch);
  21. }
  22.  
  23. Dousset.product.setCurrentWindowWidthMin();
  24.  
  25. $(window).resize(Dousset.product.windowResized);
  26.  
  27.  
  28. },thumbClicked: function (e) {
  29.  
  30. e.preventDefault();
  31.  
  32. if (!$(this).hasClass('active')) {
  33.  
  34. var postId = $(this).data('post-id');
  35. var newImg = $(this).data('image');
  36.  
  37. $('.main-image[data-post-id="'+postId+'"]').attr('src',newImg);
  38.  
  39. $('.product-thumbnail[data-post-id="'+postId+'"]').removeClass('active');
  40. $(this).addClass('active');
  41.  
  42. }
  43.  
  44. },scrollThumbsLeft: function (e) {
  45.  
  46. var $inner = $(this).siblings('.scrollable-area').find('.product-gallery-inner');
  47.  
  48. var maxMargin = $inner.width() - $(this).siblings('.scrollable-area').width();
  49.  
  50.  
  51. Dousset.product.currentInterval = setInterval(function(){
  52.  
  53. if (parseInt($inner.css('margin-left'),10) >= -maxMargin) {
  54.  
  55. $inner.css({
  56. 'margin-left' : '-=1'
  57. });
  58. }
  59.  
  60. },10);
  61.  
  62. },scrollThumbsRight: function (e) {
  63.  
  64. var $inner = $(this).siblings('.scrollable-area').find('.product-gallery-inner');
  65.  
  66. Dousset.product.currentInterval = setInterval(function(){
  67.  
  68. if (parseInt($inner.css('margin-left'),10) <= 0 ) {
  69.  
  70. $inner.css({
  71. 'margin-left' : '+=1'
  72. });
  73. }
  74.  
  75. },scrollThumbsLeftBatch: function (e) {
  76.  
  77. var $inner = $(this).siblings('.scrollable-area').find('.product-gallery-inner');
  78.  
  79. var maxMargin = $inner.width() - $(this).siblings('.scrollable-area').width();
  80.  
  81. if (parseInt($inner.css('margin-left'),10) >= -maxMargin) {
  82.  
  83. $inner.animate({
  84. 'margin-left' : '-=70'
  85. });
  86. }
  87.  
  88. },scrollThumbsRightBatch: function (e) {
  89.  
  90. var $inner = $(this).siblings('.scrollable-area').find('.product-gallery-inner');
  91.  
  92. if (parseInt($inner.css('margin-left'),10) <= 0 ) {
  93.  
  94. $inner.animate({
  95. 'margin-left' : '+=70'
  96. });
  97. }
  98.  
  99. },setCurrentWindowWidthMin: function () {
  100.  
  101. Dousset.product.currentWindowWidthMin = $( window ).width() > 979 ? 980 : $( window ).width() > 767 ? 768 : 480;
  102.  
  103. },windowResized: function () {
  104.  
  105. var oldWinMin = Dousset.product.currentWindowWidthMin;
  106. Dousset.product.setCurrentWindowWidthMin();
  107.  
  108. }
  109.  
  110. }
  111.  
  112. $(document).ready(function(){
  113. Dousset.product.init();
  114. });

解决方法

我不能说为什么这个工作,或者只是这个,但我为标签添加了宽度和高度,并将动画移动到css3而不是jQuery.

这似乎可以解决问题.您可以访问上面的链接查看.

感谢任何人的尝试.

感谢@JoshC进行这些代码编辑.

猜你在找的HTML相关文章