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

网站建设 2021-07-03 08:15www.dzhlxh.cn网站建设

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

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


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

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

经过测试,得出狼蚁网站SEO优化的解决方案代码(放在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);
}

Copyright © 2016-2025 www.dzhlxh.cn 金源码 版权所有 Power by

网站模板下载|网络推广|微博营销|seo优化|视频营销|网络营销|微信营销|网站建设|织梦模板|小程序模板