[英]Include between navbar and vertical menu
我目前正在創建我的第一個網站,遇到了一些麻煩,我想在導航欄和豎線之間包含一個頁面,並且我想更改為頁面,以在單擊豎線的按鈕時包括在內。 這是屏幕: 我的網站的屏幕
這是我的代碼:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Memeable | The 1# world meme generator</title>
<link href="css/bootstrap.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="js/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
<link href="css/bootstrap-social.css" rel="stylesheet">
</head>
<body>
<div >
<?php
include("head.php");
?>
</div>
</body>
這是我的head.php:
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">Memeable</a>
<a href="http://www.facebook.com" class="fa fa-facebook "></a>
<a href="http://www.twitter.com" class="fa fa-twitter "></a>
</div>
</div>
</nav>
<div class="vertical-menu">
<a href="#" class="" id = "first">Premier</a>
<a href="#" class = "">Deuxième</a>
<a href="#" class = "">Troisième</a>
<a href="#" class = "">Quatrième</a>
</div>
我確定解決方案很簡單,但我不知道該怎么做。 謝謝您的幫助 !
要在“內容區域”中顯示您的內容,請使用include
。 您提供要加載的文件名作為參數。 使用數組指定要使用的所有有效文件,然后使用$_GET
參數選擇要加載的正確子頁面。
<?php
$files = array();
$files['home'] = 'home.php';
$files['contact'] = 'contact.php';
$files['whatever'] = 'you_want.php';
?>
然后,在您希望顯示內容的位置使用以下代碼:
<?php
if (isset($_GET['nav'], $files[$_GET['nav']])) {
include $files[$_GET['nav']];
} else {
include $files['home']; // default page
}
?>
要“調用”右側的子頁面,請將?nav=...
查詢參數添加到您的網址中,例如
<ul>
<li><a href="index.php?nav=home">Home</a></li>
<li><a href="index.php?nav=contact">Contact</a></li>
</ul>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.