/* background-size is only for css3, so, ie8 do not support it.
* bacdground-size contain is different from background-size: 100%, auto; or something like that,
* contain will stretch the photo, with auto will not.
// need to initialize the first and respond to the change.
var h=$('#img_detail_hidden').height();
var w=$('#img_detail_hidden').width();
if (h>w && h>348){
$("#imagDetail").css('background-size','auto 100%');
}else if (w>h && w>342){
$("#imagDetail").css('background-size','100% auto');
}else{
$("#imagDetail").css('background-size','auto auto');
}
$('#img_detail_hidden').load(function(){
var h=$(this).height();
var w=$(this).width();
if (h>w && h>348){
$("#imagDetail").css('background-size','auto 100%');
}else if (w>h && w>342){
$("#imagDetail").css('background-size','100% auto');
}else{
$("#imagDetail").css('background-size','auto auto');
}
//$(".photo_loading").hide();
});
*/
如上所示,background-size 的一些问题。如果希望ie8使用contain 或者是cover的话,可以使用这个插件:
https://github.com/louisremi/jquery.backgroundSize.js
这个很棒,但是不能获得auto的那种效果。
评论
发表评论