【问题标题】:Bootstrap responsiveness not working in ie8 on a wordpress site引导响应在 wordpress 网站上的 ie8 中不起作用
【发布时间】:2013-12-30 16:07:48
【问题描述】:

我在 23 岁时将我的网站创建为 Wordpress 的子主题。我已经集成了 Bootstrap,一切正常。 IE8 除外。页面一直卡在移动视图中。

我已按照 Bootstraps 页面上的说明,并在我的 CSS 之后的 head-tag 中包含了 respond.js。我还包括了 html5shiv。但它仍然是一样的,页面是 100% 宽度并且都是一列。

我也尝试将 http-equiv 设置为 x-ua-compatible。我的头部标签如下所示:

<head>
    <meta charset="<?php bloginfo( 'charset' ); ?>">
    <meta name="viewport" content="width=device-width">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title><?php wp_title( '|', true, 'right' ); ?></title>
    <link rel="profile" href="http://gmpg.org/xfn/11">
    <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">

    <?php wp_head(); ?>

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
      <script src="<?php echo get_stylesheet_directory_uri(); ?>/js/respond.min.js"></script>
    <![endif]-->
</head>

我的 LESS 样式表是这样开始的:

我知道 response 不适用于使用 @import 导入的 CSS,但第一次导入中的 CSS 不需要由 respond.js 操作,并且 Bootstrap-import 是 LESS 导入,因此生成的 CSS将整个引导程序和我自己的引导程序放在同一个文件中。

/*
Theme Name:     Public Web
Description:    Public Web theme, responsive and HTML5 compatible
Author:         Me
Author URI:     http://stinaq.me
Template:       twentythirteen
Version:        1.0.0
*/

@import url("../twentythirteen/style.css");
@import "bootstrap/bootstrap-min.less";

我尝试过Bootstrap的缩小版和常规版,以及IE(兼容模式和真正的IE8。respond.js是浏览器找到的,所以也不可能。

编辑:

我在本地 XAMPP 服务器上运行该站点,因此不尝试通过 //file 而是通过 localhost 访问 response.js

【问题讨论】:

  • 在视口元标记中添加intial-scale=1.0 怎么样?你试过吗?所以&lt;meta name="viewport" content=width=device-width, initial-scale=1.0"&gt;
  • 现在试过了,没用
  • 我总是检查任何我试图在上面进行兼容性测试的站点的服务器日志。通常这是浪费时间,因为您没有使用 IE8 的访问者。检查并节省一些时间。

标签: css wordpress twitter-bootstrap internet-explorer-8


【解决方案1】:

我在 wordpress 中使用的 bootstrap 3 也遇到了类似的问题。它在除 IE8 及更低版本的所有浏览器中都能正常工作。媒体查询不再起作用。今天我弄清楚发生了什么。这是一个@import 问题。我像这样将所有 CSS 文件直接包含在头文件中。

代码:

&lt;link href="&lt;?php bloginfo('template_url');?&gt;/css/bootstrap.min.css" rel="stylesheet" type="text/css" /&gt;

现在一切正常。

【讨论】:

    【解决方案2】:

    似乎错误是完全不同的。我之前遇到了一个不同的问题,这与检查器中的 html 没有正确显示有关。当我从头开始再次创建文件时,它突然起作用了。那时我使用 Sublime 而不是 Visual Studio 创建了文件,所以看起来编码不正确。 更多内容:https://wordpress.stackexchange.com/users/43535/squ

    【讨论】:

      猜你喜欢
      • 2012-05-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-23
      • 2015-10-11
      • 2019-04-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多