level 12
末班地铁1112
楼主

bootstrap是一个很好的前端UI开发框架,特别在开发自适应网页应用盛广.新的逐浪CMS版本已经开始采用此框架,从而为广大用户快速生成各类WEB app,是我们用户的大福音。但是在我们项目在开发中碰到一小问题: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);
}
更多分享来源:http://bbs.zoomla.cn/showtopic-256177.aspx