CSS不在一个文件中工作,而是在另一个文件中工作

时间:2015-02-16 15:25:20

标签: html css menu

我有2个不同的html文件(位于同一目录中)。一个文件适用于我的菜单。 http://gyazo.com/3ee7c319ceb57bb1e91efb16cc93c28d

但是,当我将完全相同的代码复制并粘贴到其他html文件中时,菜单如下所示:http://gyazo.com/ac9d43e9dcfada048dc206e735a6a5d0

以下是第一个(工作)文件的代码:

<!DOCTYPE html>
<html lang="en" class="no-js">

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Boxify: Free HTML5/CSS3 Template by Peter Finlan</title>
  <!-- Bootstrap -->
  <link href="css/bootstrap.min.css" rel="stylesheet">
  <link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
  <link href='http://fonts.googleapis.com/css?family=Nunito:400,300,700' rel='stylesheet' type='text/css'>
  <link href="css/styles2.css" rel="stylesheet">
</head>


<body>

  <div class="container">
    <div class="row nav-wrapper">
      <div class="col-md-6 col-sm-6 col-xs-6 text-right navicon">
        <p></p><a id="trigger-overlay" class="nav_slide_button nav-toggle" href="#"><span></span></a>
      </div>
    </div>


    <div class="overlay overlay-boxify">
      <nav>
        <ul>
          <li><a href="http://goldenhoney.zz.vc/index.php"><i class="fa fa-heart"></i>About</a>
          </li>
          <li><a href="#features"><i class="fa fa-flash"></i>Features</a>
          </li>
        </ul>
        <ul>
          <li><a href="#screenshots"><i class="fa fa-desktop"></i>Screenshots</a>
          </li>
          <li><a href="#download"><i class="fa fa-download"></i>Download</a>
          </li>
        </ul>
      </nav>
    </div>

    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
    <script src="js/min/scripts-min.js"></script>
</body>

</html>

以下是其他文件的代码(不起作用):

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <title>{$title}</title>
  <link rel="shortcut icon" href="{$url}/favicon.ico" />
  <link href="{$url}/{$theme_path}/{$theme_name}/style.css" rel="stylesheet" type="text/css" />
  <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0" />
  <script type="text/javascript" src="{$url}/{$theme_url}/js/jquery.js"></script>
  <script type="text/javascript" src="{$url}/{$theme_url}/js/jquery.timeago.js"></script>
  <script type="text/javascript" src="{$url}/{$theme_url}/js/functions.js"></script>
  <link rel="shortcut icon" href="../favicon.ico">

**<!-- Bootstrap -->
  <link href="css/bootstrap.min.css" rel="stylesheet">
  <link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
  <link href='http://fonts.googleapis.com/css?family=Nunito:400,300,700' rel='stylesheet' type='text/css'>
  <link href="css/styles2.css" rel="stylesheet">**
</head>

<body>
  <div class="topbar">
    <div class="header">
      <a href="{$url}">
        <div class="logo"></div>
        <div class="logo-small"></div>
      </a>
      <div class="search-input">
        <input type="text" id="search" placeholder="{$lng->search_for_people}">
      </div>
      <div class="search-container"></div>
      <div class="container">
        **<div class="row nav-wrapper">
          <div class="col-md-6 col-sm-6 col-xs-6 text-right navicon">
            <p></p><a id="trigger-overlay" class="nav_slide_button nav-toggle" href="#"><span></span></a>
          </div>
        </div>
        <div class="overlay overlay-boxify">
          <nav>
            <ul>
              <li><a href="http://goldenhoney.zz.vc/index.php"><i class="fa fa-heart"></i>About</a>
              </li>
              <li><a href="#features"><i class="fa fa-flash"></i>Features</a>
              </li>
            </ul>
            <ul>
              <li><a href="#screenshots"><i class="fa fa-desktop"></i>Screenshots</a>
              </li>
              <li><a href="#download"><i class="fa fa-download"></i>Download</a>
              </li>
            </ul>
          </nav>
        </div>
        <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
        <script src="js/min/scripts-min.js"></script>**
        {$menu}
        <div class="topbar_margin"></div>
        {$content}
        <div class="row-body">
          <div class="footer">

            <div class="footer-container">
              <div class="footer-links">
                <a href="{$url}/index.php?a=page&b=tos">{$lng->terms_of_use}</a> -
                <a href="{$url}/index.php?a=page&b=privacy">{$lng->privacy_policy}</a> -
                <a href="{$url}/index.php?a=page&b=disclaimer">{$lng->disclaimer}</a> -
                <a href="{$url}/index.php?a=page&b=api">{$lng->developers}</a> -
                <a href="{$url}/index.php?a=page&b=contact">{$lng->contact}</a> -
                <a href="{$url}/index.php?a=page&b=about">{$lng->about}</a> -
                <a href="{$url}/index.php?a=admin">{$lng->title_admin}</a>
              </div>
              <div class="footer-languages">
                {$lng->language}: {$language}
              </div>
              <div class="footer-languages">
                Copyright &copy; {$year} {$footer}. {$lng->all_rights_reserved}. {$powered_by}
              </div>
            </div>

          </div>
        </div>
        <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
        <script src="js/min/scripts-min.js"></script>
</body>

</html>

2 个答案:

答案 0 :(得分:0)

您是否尝试在文件中使用<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">而不是<link href="css/bootstrap.min.css" rel="stylesheet">。 有时路径检测不正确,这就是建议使用bootstrapcdn链接css文件的原因。

答案 1 :(得分:0)

想出来,而不是:

<script src="js/demo1.js"></script>

我用过:

<script src="http://goldenhoney.zz.vc/themes/dolphin/html/js/demo1.js"></script>

我很开心。但是为什么我以前的代码不起作用而被解雇了。