HTML和PHP:如何正确排列页面?

时间:2015-08-10 17:54:40

标签: php html

我的页面确实有问题...我的CSS目前是style.css,主页是index.php,我的所有包含的“includes”文件夹(navigation.php和header.php) )和我的register.php:http://prntscr.com/8320hv

我刚开始编写我的作品,所以没有太多。我的页面组织有问题。我想在index.php中添加一些内容:

http://prntscr.com/832496

代码:

<!DOCTYPE html>
<html lang="en-US">
<head>
    <title>Test 2</title>
    <meta charset="UTF-8">
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    <link href="css/style.css" rel="stylesheet">
    <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet">
</head>
<body>
<?php require "includes/navigation.php"; ?>

<?php require "includes/header.php"; ?>

<div class="wrapper">
    <div id="container">
        <div id="breadcrumb-top" class="breadcrumb">
            <ul>
                <li>
                    <a href="#">Home</a>
                </li>
            </ul>
        </div>
        <span class="big-title">Home</span>
        <div id="breadcrumb-bottom" class="breadcrumb">
            <ul>
                <li>
                    <a href="#">Home</a>
                </li>
            </ul>
        </div>
    </div>
</div>
</body>
</html>

但是如果我想进入我的register.php文件,我的index.php没有链接到它:http://prntscr.com/8322hn

我有义务以这种方式操作,因为我想为容器中的index.php和register.php分配不同的内容:http://prntscr.com/8323ht

我真的迷失了,所以如果我能得到帮助,我承认。

1 个答案:

答案 0 :(得分:0)

到目前为止你做得很好,你只需要在每个页面中包含每个页面的单独内容。有一个共同的导航.php是一个标准的事情,虽然我会在根文件夹中有navigation.php,这样你的相对链接更容易管理。

同一文件夹中的所有4个文件,其中stylesheet.css位于css /文件夹中:

head.php:

<head>
  <link href="css/stylesheet.css" rel="stylesheet" type="text/css">
</head>

nav.php:

<div class="nav">
  <a href="index.php> home</a> |
  <a href="register.php> register</a>
</div>

的index.php:

<html>
  <?php include "head.php"; ?>
  <body>
    <?php include "nav.php"; ?>
    <div class="container">
      <h1>This is home</h1>
    </div>
  </body>
</html>

register.php:

<html>
  <?php include "head.php"; ?>
  <body>
    <?php include "nav.php"; ?>
    <div class="container">
      <h1>This is register</h1>
    </div>
  </body>
</html>
相关问题