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

标签 php html css bootstrap-4

我目前正在学习使用 php 和模块化技术制作网络。以前我设法在 php 文件上运行 bootstrap。但是当我在目录中创建一个名为“layout”的文件夹,然后在布局文件夹中创建一个名为“index.php”的新php文件用于Web显示时,我在layout/index中使用样式表提供 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/

相关文章:

php - Laravel 5.2 Socialite Facebook 登录 cURL 错误 60

javascript - 检查图像文件的可见性

php - 上传 codeigniter 项目时 cpanel 中出现数据库错误

php函数所需参数混淆

javascript - 是否可以通过自定义 HTML 表单向 Google 表单提交多个/重复的表单字段?

css - 漂浮后的div碰撞

html - margin-top 不能正常工作

jquery - 使用jQuery在数据表中动态添加列

javascript - 你如何处理特定于浏览器的 .js 和 .css

php - 在 PHP 中显示页码