Follow along with the video below to see how to install our site as a web app on your home screen.
Примечание: This feature may not be available in some browsers.
<ul class="fixed cropcenterimg">
<li class="cuad"><img src="http://www"/></li> - квадратом
<li class="vert"><img src="http://www"/></li> - центровка по ширине
<li class="hor"><img src="http:/"/></li> - центровка по высоте
</ul>
ul, li{
list-style:none;
margin:0;
padding:0;
}
img{
display:block;
margin:0;
}
ul{
overflow:hidden;
display:block;
li{
display:block;
float:left;
margin-right:10px;
overflow:hidden;
text-align:center;
border:3px solid #ccc;
}
}
.hor{
width:200px;
height:140px;
}
.vert{
width:160px;
height:200px;
}
.cuad{
width:200px;
height:200px;
}
.resp{
li{
width:30%;
height:200px;
}
}
$(function() {
CenterCropImage($('.cropcenterimg li'))
$(window).resize(function(){
CenterCropImage($('.cropcenterimg li'))
})
})
function CenterCropImage(x){
x.each(function(){
$(this).children('img').load(function(){
ContentBox=$(this).parent()
PropBox=getProportions(ContentBox)
ImgtoResize=$(this)
PropImg=getProportions(ImgtoResize)
if(PropBox>PropImg){
ProportionVertical(ImgtoResize)
}
else{
ProportionHorizontal(ImgtoResize)
}
})
ContentBox=$(this)
PropBox=getProportions(ContentBox)
ImgtoResize=$(this).children('img')
PropImg=getProportions(ImgtoResize)
if(PropBox>PropImg){
ProportionVertical(ImgtoResize)
}
else{
ProportionHorizontal(ImgtoResize)
}
})
}
function getProportions(x){
Height=x.height()
Width=x.width()
Prop=Width/Height
return Prop
}
function ProportionHorizontal(x){
x.removeAttr("style")
x.css({'height':'100%','width':'auto'})
Wimg=x.width()
Wcont=x.parent().width()
MarginLeft=(Wcont-Wimg)/2
x.css({'margin-left':MarginLeft})
}
function ProportionVertical(x){
x.removeAttr("style")
x.css({'width':'100%','height':'auto'})
Himg=x.height()
Hcont=x.parent().height()
MarginTop=(Hcont-Himg)/2
x.css({'margin-top':MarginTop})
}