gpt4 book ai didi

php - 使用模块化技术时,如何修复 bootstrap 在 layout/index.php 中的 php 文件中不起作用?

转载 作者:行者123 更新时间:2023-11-27 22:55:52 25 4
gpt4 key购买 nike

我目前正在学习使用 php 和模块化技术制作网页。以前我设法在 php 文件上运行 Bootstrap 。但是当我在我的目录中创建一个名为“layout”的文件夹,然后在布局文件夹中创建一个名为“index.php”的新 php 文件用于网络显示时,我在布局/索引中提供带有样式表的 Bootstrap .php,事实证明 Bootstrap 不起作用。

Take a look in my directory

这是我的 index.php

<?php

$modul =isset($_GET['modul'])?$_GET['modul']:'default';

$action = isset($_GET['action'])?$_GET['action']:'index';

include 'layout/index.php';
?>

这里是 layout/index.php

<!DOCTYPE html>
<html>
<head>
<title>MAIN MENU</title>
<link rel="stylesheet" href="../bootstrap/css/bootstrap.min.css" media="screen">
<meta charset="UTF-8">
<meta name="viewport" content="width = device-width, intial-scale=1">
<style>
body {
text-align: center;
}
section{
background-color: white;
margin: 25px 0px;
padding: 25px;
border: solid black;
border-radius: 25px;
}
</style>
</head>
<body>
<header>
<div class="jumbotron text-center text-light bg-danger" style="margin-bottom: 5px">
<h1>PHP <br> TEKNIK MODULASI FILE DAN DIREKTORI</h1>
</div>
</header>
<nav class="navbar navbar-expand-sm bg-danger navbar-dark justify-content-center">
<ul class="navbar-nav">
<li class="nav-item"><a class="nav-link" href="index.php?modul=menu1">Kalkulator</a></li>
<li class="nav-item"><a class="nav-link" href="index.php?modul=menu2">Menu2</a></li>
<li class="nav-item"><a class="nav-link" href="index.php?modul=menu3">Menu3</a></li>
<li class="nav-item"><a class="nav-link" href="index.php?modul=menu4">Menu4</a></li>
<li class="nav-item"><a class="nav-link" href="index.php?modul=mahasiswa">Mahasiswa</a></li>
</ul>
</nav>
<section class="container">
<article>
<!--- ini adalah content--->
<?php

include 'modul/'.$modul.'/'.$action.'.php';

?>
</article>
</section>

<footer class="py-5 bg-danger">
<div class="container">
<p class="m-0 text-center text-white">Copyright &copy; 2019 Imam Faried Helmi</p>
</div>
<!-- /.container -->
</footer>
</body>
</html>

Here's the result, bootstrap is not working

当我拿到这个代码的时候

<link rel="stylesheet" href="../bootstrap/css/bootstrap.min.css" media="screen">

进入 index.php Bootstrap 工作。但为什么 bootstrap 在 layout/index.php 中不起作用?

有人知道怎么解决吗?请帮助我:)

最佳答案

<link rel="stylesheet" href="/bootstrap/css/bootstrap.css" media="screen">

这肯定会奏效。由于您尚未添加 bootstrap.min.css,请先检查。

关于php - 使用模块化技术时,如何修复 bootstrap 在 layout/index.php 中的 php 文件中不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55923650/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com