Commit fc5758dd by 邓丽

fixmargin

parent e02f1dfb
...@@ -1477,6 +1477,18 @@ ...@@ -1477,6 +1477,18 @@
_.$slider.trigger('lazyLoaded', [_, image, imageSource]); _.$slider.trigger('lazyLoaded', [_, image, imageSource]);
}); });
/*图片宽高自适应展示*/
var windowW = parseInt($(window).width());//获取浏览器的宽度
var windowH = parseInt($(window).height());//获取浏览器的宽度
var realWidth = imageToLoad.width;;
var realHeight = imageToLoad.height;;
if(windowW<640) {
var bi = (realHeight / realWidth).toFixed(2);
var Top = parseInt((windowH - parseInt(windowW * bi)) / 2);
image.attr('style', 'margin-top:' + Top+'px');
}
}; };
imageToLoad.onerror = function() { imageToLoad.onerror = function() {
...@@ -1492,18 +1504,6 @@ ...@@ -1492,18 +1504,6 @@
imageToLoad.src = imageSource; imageToLoad.src = imageSource;
/*图片宽高自适应展示*/
var windowW = parseInt($(window).width());//获取浏览器的宽度
var windowH = parseInt($(window).height());//获取浏览器的宽度
if(windowW<640) {
var realWidth;
var realHeight;
realWidth = imageToLoad.width;
realHeight = imageToLoad.height;
var bi = (realHeight / realWidth).toFixed(2);
var Top = parseInt((windowH - parseInt(windowW * bi)) / 2);
image.attr('style', 'margin-top:' + Top+'px');
}
}); });
} }
......
...@@ -1476,32 +1476,13 @@ ...@@ -1476,32 +1476,13 @@
}); });
_.$slider.trigger('lazyLoaded', [_, image, imageSource]); _.$slider.trigger('lazyLoaded', [_, image, imageSource]);
}); });
};
imageToLoad.onerror = function() {
image
.removeAttr( 'data-lazy' )
.removeClass( 'slick-loading' )
.addClass( 'slick-lazyload-error' );
_.$slider.trigger('lazyLoadError', [ _, image, imageSource ]);
};
imageToLoad.src = imageSource;
/*图片宽高自适应展示*/ /*图片宽高自适应展示*/
var windowW = parseInt($(window).width());//获取浏览器的宽度 var windowW = parseInt($(window).width());//获取浏览器的宽度
var windowH = parseInt($(window).height());//获取浏览器的宽度 var windowH = parseInt($(window).height());//获取浏览器的宽度
var realWidth = imageToLoad.width;
var realHeight = imageToLoad.height;
var Top=0;
if(windowW>640){ if(windowW>640){
var realWidth;
var realHeight;
realWidth = imageToLoad.width;
realHeight = imageToLoad.height;
var bi=(realHeight / realWidth).toFixed(2); var bi=(realHeight / realWidth).toFixed(2);
var mH=parseInt(windowW * bi); var mH=parseInt(windowW * bi);
var Top=parseInt((windowH - realHeight)/2); var Top=parseInt((windowH - realHeight)/2);
...@@ -1519,6 +1500,20 @@ ...@@ -1519,6 +1500,20 @@
image.attr('style','margin-top:'+Top+'px;width:auto; height:auto;'); image.attr('style','margin-top:'+Top+'px;width:auto; height:auto;');
} }
} }
};
imageToLoad.onerror = function() {
image
.removeAttr( 'data-lazy' )
.removeClass( 'slick-loading' )
.addClass( 'slick-lazyload-error' );
_.$slider.trigger('lazyLoadError', [ _, image, imageSource ]);
};
imageToLoad.src = imageSource;
}); });
} }
......
...@@ -131,21 +131,20 @@ var _h = parseInt($(window).height());//获取浏览器的宽度 ...@@ -131,21 +131,20 @@ var _h = parseInt($(window).height());//获取浏览器的宽度
$(".title h2").css("top",hTop); $(".title h2").css("top",hTop);
$(".title p").css("top",pTop); $(".title p").css("top",pTop);
$("#portfolioDel div").css({ $("#portfolioDel div").css({
"width":'100%',
"height":_h "height":_h
}) })
} }
} }
$(window).resize(function() {
$(function(){
indexImg(); indexImg();
}) })
$(window).resize(function() { $(function(){
indexImg(); indexImg();
}) })
</script> </script>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
<ul class="slider lazy portfolioSiles" id="portfolioDel"> <ul class="slider lazy portfolioSiles" id="portfolioDel">
<li> <li>
<div> <div>
<img class="image" data-lazy="http://www.zhongweixing.com/media/gallery/15/283be29e043ee8fc7883dea1efec63da.png" /> <img class="image" data-lazy="http://www.zhongweixing.com/media/gallery/15/283be29e043ee8fc7883dea1efec63da.png" style="margin-top:100px;" />
</div> </div>
</li> </li>
<li> <li>
...@@ -112,6 +112,9 @@ ...@@ -112,6 +112,9 @@
slidesToShow: 1, slidesToShow: 1,
slidesToScroll: 1, slidesToScroll: 1,
speed: 500 speed: 500
/* init:function(){
$("img.image").attr("style","margin-top:100px;")
}*/
}); });
</script> </script>
</body> </body>
......
...@@ -59,7 +59,7 @@ $(function(){ ...@@ -59,7 +59,7 @@ $(function(){
/*图片懒加载*/ /*图片懒加载*/
$("img.lazy").lazyload({ $("img.lazy").lazyload({
placeholder : "../images/transparent.gif", placeholder : "./images/transparent.gif",
threshold:100, threshold:100,
effect: "fadeIn", effect: "fadeIn",
event: 'scroll', event: 'scroll',
......
...@@ -83,21 +83,20 @@ var _h = parseInt($(window).height());//获取浏览器的宽度 ...@@ -83,21 +83,20 @@ var _h = parseInt($(window).height());//获取浏览器的宽度
$(".title h2").css("top",hTop); $(".title h2").css("top",hTop);
$(".title p").css("top",pTop); $(".title p").css("top",pTop);
$("#portfolioDel div").css({ $("#portfolioDel div").css({
"width":'100%',
"height":_h "height":_h
}) })
} }
} }
$(window).resize(function() {
$(function(){
indexImg(); indexImg();
}) })
$(window).resize(function() { $(function(){
indexImg(); indexImg();
}) })
</script> </script>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
<ul class="slider lazy portfolioSiles" id="portfolioDel"> <ul class="slider lazy portfolioSiles" id="portfolioDel">
<li> <li>
<div> <div>
<img class="image" data-lazy="http://www.zhongweixing.com/media/gallery/15/283be29e043ee8fc7883dea1efec63da.png" /> <img class="image" data-lazy="http://www.zhongweixing.com/media/gallery/15/283be29e043ee8fc7883dea1efec63da.png" style="margin-top:100px;" />
</div> </div>
</li> </li>
<li> <li>
...@@ -64,6 +64,9 @@ ...@@ -64,6 +64,9 @@
slidesToShow: 1, slidesToShow: 1,
slidesToScroll: 1, slidesToScroll: 1,
speed: 500 speed: 500
/* init:function(){
$("img.image").attr("style","margin-top:100px;")
}*/
}); });
</script> </script>
</body> </body>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment