简体   繁体   English

如何使标题和侧边栏保持不变?

[英]How do I make header and sidebar stay?

This is my index.php file 这是我的index.php文件

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="style.css" />
    <style type="text/css">
    </style>
</head>
<body>
   <div id="container">
   <?php
    include('includes/header.php');
    include('includes/sidebar.php');
    include('includes/content.php');
    include('includes/footer.php');
?>
</body>
</html>

This is code for my sidebar.php 这是我的sidebar.php的代码

<div id="sidebar">
<ul id="list">
    <li><a href="index.php" class="sidebar">Home</a></li>
    <li><a href="flower.php" class="sidebar">flower</a></li>
    <li><a href="study.php" class="sidebar">Study</a></li>
    <li><a href="calendar.php" class="sidebar">Calendar</a></li>
    <li><a href="diary.php" class="sidebar">Diary</a></li>
</ul>

if I click flower, it will go to flower.php. 如果单击flower,它将转到flower.php。 I didn't include header, sidebar, and footer, and found that it shows only contents of flower.php, not showing header, sidebar, and footer. 我没有包含页眉,侧边栏和页脚,但发现它仅显示flower.php的内容,而不显示页眉,侧栏和页脚。 Is there any way to make it showing? 有什么办法让它显示出来吗? Or should I just write down all the code below again? 还是应该再次写下下面的所有代码?

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="style.css" />
    <style type="text/css">
    </style>
</head>
<body>
   <div id="container">
   <?php
    include('includes/header.php');
    include('includes/sidebar.php');
    include('includes/content.php');
    include('includes/footer.php');

You should use your header, footer and sidebar on each of your page, because it won't create any problem because if you need to make change you would only change in required file and the change will occur in all other files as well. 您应该在每个页面上使用页眉,页脚和侧栏,因为它不会造成任何问题,因为如果您需要进行更改,则只会更改所需的文件,并且所有其他文件也会进行更改。 While content.php you should have your specific code for each page separately. 当使用content.php时,您应该分别为每个页面使用特定的代码。 Hope this help 希望这个帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM