Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

page子元素的尺寸问题 #9

Closed
howyhuang opened this issue Jul 5, 2016 · 1 comment
Closed

page子元素的尺寸问题 #9

howyhuang opened this issue Jul 5, 2016 · 1 comment

Comments

@howyhuang
Copy link

请教下大神,page里面的子元素尺寸怎么设置呢,比如设计稿750*1334
我子元素写px 还是用scss计算写rem来布局,还是直接img作为子元素用百分比,
我现在是 js计算设定html的dpi,用rem来布局,但是无论我用什么方案 在ip4 ip5等不一样机型都会和设计稿有差异,哎 好头疼,大神有什么好的方案么
联系邮箱 [email protected]

@littledu
Copy link
Member

littledu commented Jul 8, 2016

这个组件主要针对一些运营类活动,比如微信朋友圈的广告落地页,一些产品宣传页等,他们都有个特点就是一屏一屏的滑动,这类页面的适配其实不适合 rem 这类常规的适配写法,对于这类页面,最快速最简单的适配是直接等比放大缩小,这里提供一段代码,基于微信的可视尺寸适配的方案,希望对你有帮助:

    // 放大元素,按照320x504定位,按比例scale
    function scaleEle(selector,position){
        var pageScale;
        var currentScale=screenWidth/screenHeight;
        var originScale=320/504;
        if(currentScale>originScale){
            pageScale=screenHeight/504;
        }else{
            pageScale=screenWidth/320;
        }
        $(selector).css({"-webkit-transform-origin":position,"transform-origin":position,"-webkit-transform":"scale("+pageScale+");","transform":"scale("+pageScale+");"});
    }

    var screenHeight = document.documentElement.clientHeight,
        screenWidth = document.documentElement.clientWidth;

    scaleEle(".mod-page-list__page","center");

@littledu littledu closed this as completed Jul 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants