javascript - 2048界面不能屏幕自适应

查看:83
本文介绍了javascript - 2048界面不能屏幕自适应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

$(document).ready(function() {

prepareForMobile();
newgame();

})

function prepareForMobile(){

if( documentWidth > 500){
    gridContainerWidth = 460;
    cellSpace = 20;
    cellSideLength = 100;
}
$('#grid-container').css('width', gridContainerWidth );
$('#grid-container').css('height', gridContainerWidth);
$('#grid-container').css('padding', cellSpace);
$('#grid-container').css('border-radius', 0.02*gridContainerWidth);

$('.grid-cell').css('width', cellSideLength);
$('.grid-cell').css('height', cellSideLength);
$('.grid-cell').css('border-radius', 0.02*cellSideLength);

}

为什么我这个代码不能实现屏幕自适应,出现下图情况

解决方案

html代码也贴出来看看?用控制台看看,有没有什么其他的东西。

这篇关于javascript - 2048界面不能屏幕自适应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆