CSS使用transform:scale()来制作响应式html横幅

时间:2017-03-27 12:38:15

标签: javascript html css responsive-design

我有非常复杂的html横幅。应用媒体查询并使其响应需要数天时间。我只想使用javascript和css转换:scale()。这样的事情:

parentWidth = $('#banner').parent().width();
bannerWidth = $('#banner').width();
if(parentWidth<=bannerWidth || originWidth>bannerWidth){
  rate = (originWidth-parentWidth)/originWidth;
  if(parentWidth>originWidth){
    scale = 1;
  }else{
    scale = 1-rate;
  }    
  $("#banner").css('transform','scale('+scale+')');
}

通过这种方式,它的行为与宽度=“100%”的横幅图像相同。我知道有些文字会变得非常小。除此之外,是否有任何潜在的问题可能出现在不同的浏览器?我在我的电脑上对它进行了测试,它工作正常,但我可能不知道某些事情。

TNX!

0 个答案:

没有答案