0

matchmedia クエリを部分的に機能させることができました。つまり、ウィンドウのロードでは機能しますが、サイズ変更では機能しません。私はこれに本当に慣れていないので(したがってくだらない質問です)、気楽にゆっくり話してください。画面が変わったりページが読み込まれたりするたびに発火させようとしています。

http://codepen.io/anon/pen/XJZOMw

function mediaqueryresponse(screencheck){

    if (screencheck.matches){

        function introHeight(){

            var introheight = document.getElementById("bottom").offsetHeight;


            document.getElementById("introtext").style.top =(180 - introheight) + "px";
            //document.write (introheight);
            }

        //document.onresize = introHeight;
        window.onresize = introHeight;
        }

}       
var screencheck = window.matchMedia("all and (max-width: 419px)");
mediaqueryresponse(screencheck); // call listener function explicitly at run time
screencheck.addListener(mediaqueryresponse); // attach listener function to listen in on state changes

これが重複している、または単にがらくたのプログラミングである、および/または不十分に書かれている、または間違った場所にある場合は、ありがとうございます。

4

0 に答える 0