网页制作 
首页 > 网页制作 > 浏览文章

Bootstrap在windows phone 8下不兼容的解决方法

(编辑:jimmy 日期: 2024/5/20 浏览:3 次 )

bootstrap是一款非常优秀的前端UI开发框架,特别在开发自适应网页应用广泛。然而bootstrap在windows phone 8中会出现整个屏幕变得很小的情况。经过分析找出原因是:

bootstrap.css文件中有这样一行代码:


复制代码代码如下:@-ms-viewport {
width: device-width;
}

这行代码作用是:页面宽度被设置成设备的宽度.而在实际中,我并不是我想要的结果,我们需要根据我的网页内容自动适应。

经过测试,得出下面的解决方案代码(放在header里脚本中):


复制代码代码如下:if (navigator.userAgent.match(/IEMobile\/10\.0/)) {
var msViewportStyle = document.createElement("style");
msViewportStyle.appendChild(
document.createTextNode(
"@-ms-viewport{width:auto!important}"
)
);
document.getElementsByTagName("head")[0].appendChild(msViewportStyle);
}

上一篇:细说CSS3中box属性中的overflow-x属性和overflow-y属性值的效果
下一篇:html td nowrap不换行属性使用方法
友情链接:杰晶网络 DDR爱好者之家 南强小屋 黑松山资源网 白云城资源网