在chrome(django)中体内呈现的元标记

时间:2015-01-05 18:32:48

标签: html django html5 twitter-bootstrap

django 应用中的html模板如下所示:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>sth</title>


    <!-- Bootstrap -->
    <link href="static/css/bootstrap.min.css" rel="stylesheet" type="text/css" />

</head>
<body id="page-top" class="index" data-spy="scroll" data-offset="0">

    <!-- Navigation -->
    <nav class="navbar navbar-default navbar-fixed-top">
        <div class="container">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header page-scroll">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#my-navbar">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand page-scroll" href="#page-top">STH</a>
            </div>

            <div class="collapse navbar-collapse" id="my-navbar">

                <ul class="nav navbar-nav">
                    <li class="hidden">
                        <a href="#page-top"></a>
                    </li>
                    <li><a class="page-scroll" href="#a1">a1</a></li>
                    <li><a class="page-scroll" href="#a2">a2</a></li>
                    <li><a class="page-scroll" href="#a3">a3</a></li>
                    <li><a class="page-scroll" href="#a4">a4</a></li>
                </ul>

                <ul class="nav navbar-nav navbar-right">
                    <li><a href="/logout/">Logout</a></li>
                </ul>

            </div>
        </div>
    </nav>

    <!-- Header -->
    <header>
        <div class="container">
            <div class="intro-text">
                <div class="intro-heading">Heading!</div>
            </div>
        </div>
    </header>


    <!-- Content to extend -->

    <section id="a1">
        <div class="container">
            Lots of Text
        </div>
    </section>

    <section id="a2">
        <div class="container">
            Lots of Text ...
        </div>
    </section>

    <section id="a3">
        <div class="container">
            Lots of Text ...
        </div>
    </section>

    <section id="a4">
        <div class="container">
            Lots of Text ...
        </div>
    </section>

    <!-- Footer -->
    <footer>
        <div class="container">
            <h4>

                Footer

            </h4>
        </div>
    </footer>



    <!-- jQuery -->
    <script src="/static/js/jquery.js"></script>
    <!-- Bootstrap Core JavaScript -->
    <script src="/static/js/bootstrap.min.js"></script>

    <!-- Plugin JavaScript -->
    <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js"></script>
    <script src="/static/js/classie.js"></script>
    <script src="/static/js/cbpAnimatedHeader.js"></script>

    <script src="/static/parsley/parsley.js"></script>
</body>
</html>

在Firefox中一切正常

在chrome中,这个html呈现如下:

<html lang="en">
#shadow-root
<shadow></shadow>
<style type="text/css"></style>
<head></head>
<body>
"



"
      <meta charset="utf-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <meta name="description" content="">
      <meta name="author" content="m">
      <title>Sth</title>

      <!-- Bootstrap -->
     <link href="/static/css/bootstrap.min.css" rel="stylesheet" type="text/css" >
     ...

所以meta和其他css都在body元素里面。我认为因为bootstrap中的某些东西没有正常工作(例如dataspy)。 (当我使用&#34;来源&#34;选项卡检查我的文件的html时,所有内容似乎都正常&#34;,但在&#34; Elements&#34;标签中显示的内容如上所述奇怪。)< / p>

正如我所提到的,我使用Django和Bootstrap

2 个答案:

答案 0 :(得分:2)

问题在于编码。我在IDE中将默认保存设置设置为“带签名的UTF8”,但应该是“没有签名的UTF8”。

我希望它会对某人有所帮助。

答案 1 :(得分:-1)

关闭标题并添加正文标记

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="m">
<title>Sth</title>

{% load staticfiles %}
<!-- Bootstrap -->
<link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet" type="text/css" />
</head>
<body>
...
</body>