2016-12-26 55 views
1

我有一个非常简单的注册网页,包含标题,登记表和页脚如何把CSS放在所有的PHP页面上?

头是包含菜单header.php文件,它是在我已经把链接CSS这个PHP文件文件。 Registration.php仅包含注册表单。

问题是,当我想修改菜单的高度(它在header.php中,它也包含css链接)它的工作原理,但如果我想改变一些在registration.php它不'工作。

我知道这是因为CSS是在header.php上,但如何让所有包含“header.php”的页面的CSS更“全局”?

这是我的header.php:

<!DOCTYPE html> 
<html> 


<head> 
    <meta charset="utf-8"> 

    <!-- CSS --> 
    <link href="css/style.css" rel="stylesheet" type="text/css" title="style.css"> 

    <title>Safran | Home</title>  
</head> 
<body> 
    <div class="menu-bloc"> 
     <div class="menu-wrapper menu-desktop"> 
      <span class="menu-logo-bloc"></span> 

      <ul class="navigation-menu"> 
       <li class="menu-item"><a href="login.php">Login</a></li> 
       <li class="menu-item"><a href="registration.php">Sing up</a></li> 
      </ul> 
     </div> 

     <!-- MENU MOBILE --> 
     <div class="menu-mobile" style="display:none;"> 
      <span class="menu-logo-bloc"> 
       <img src="assets/mobile/menu-mobile-btn.png"> 
      </span> 
     </div> 
    </div> 

,这是我和registration.php页:

<!-- php includes --> 
    <!-- menu --> 
    <?php 
     require "header.php"; 
    ?> 
     <form method="POST" action="registration.php"> 
      <label div="label_registration" for="username_input">Nom d'utilisateur</label> 
      <input type="text" name="username_input"> 

      <label div="label_registration" for="email_input">Email</label> 
      <input type="text" name="email_input"> 

      <label div="label_registration" for="password_input">Mot de passe</label> 
      <input type="password" name="password_input"> 

      <label div="label_registration" for="password_input_confirm">Confirmer le mot de passe</label> 
      <input type="password" name="password_input_confirm"> 

      <button style="submit" class="btn btn-green btn-create" name="register_btn">créer mon compte</button> 

     </form> 


    </div> 
    <?php require "footer.php"; ?> 

即使 “header.php文件” 包含CSS,以及 “为registration.php”包含“header.php”,当我尝试修改标签的文本颜色,例如“registration.php”时,它不起作用。

+2

您将需要一个'php_include'添加CSS文件在你registration.php的文件中。 –

+1

为什么注册页面的html输出不包含header.php文件的输入?换句话说,您的服务器如何在不添加header.php文件的内容的情况下构建您的注册页面? – 2016-12-26 18:00:02

+0

谢谢大家,我正在尝试php包含函数,但是您可以检查一下mon编辑吗? – Sushi

回答

0

使用任何PHP文件并在该文件中编写您的CSS链接。然后在您可以访问的主PHP文件中使用require或require_once。

例如test.php的

<?php 
<link rel="stylesheet" href="src file"> 
?> 

在main.php