[英]Load CSS into a PHP file
大家。 我正在按照教程創建注冊和登錄系統,我是第一次這樣做。 我無法設置 PHP 文件中的 HTML 表單的樣式。 I just have one folder with 6 files (error.php, index.php, login.php, register.php, server.php, style.css) So far I have just wrote code in the register.php and style.css files . And I get this messages from the console in the register.php file: 1- "The stylesheet http://localhost/registration/register.php/style.css was loaded as CSS even though its MIME type, “text/html” , 不是“文本/css”。”
2-“由於選擇器錯誤而忽略了規則集。”
怎么了? 我正在使用 XAMPP
這是代碼:
寄存器.php:
<?php
include('server.php');
?>
<!DOCTYPE html>
<html>
<head>
<title>Registration system PHP and MySQL</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="header">
<h2>Register</h2>
</div>
<form method="post" action="register.php">
<?php
include('errors.php');
?>
<div class="input-group">
<label>Username</label>
<input type="text" name="username" value="<?php
echo $username;
?>">
</div>
<div class="input-group">
<label>Email</label>
<input type="email" name="email" value="<?php
echo $email;
?>">
</div>
<div class="input-group">
<label>Password</label>
<input type="password" name="password_1">
</div>
<div class="input-group">
<label>Confirm password</label>
<input type="password" name="password_2">
</div>
<div class="input-group">
<button type="submit" class="btn" name="reg_user">Register</button>
</div>
<p>
Already a member? <a href="login.php">Sign in</a>
</p>
</form>
</body>
</html>
樣式.css:
* {
margin: 0px;
padding: 0px;
}
body {
font-size: 120%;
background: #F8F8FF;
}
.header {
width: 30%;
margin: 50px auto 0px;
color: white;
background: #5F9EA0;
text-align: center;
border: 1px solid #B0C4DE;
border-bottom: none;
border-radius: 10px 10px 0px 0px;
padding: 20px;
}
form, .content {
width: 30%;
margin: 0px auto;
padding: 20px;
border: 1px solid #B0C4DE;
background: white;
border-radius: 0px 0px 10px 10px;
}
.input-group {
margin: 10px 0px 10px 0px;
}
.input-group label {
display: block;
text-align: left;
margin: 3px;
}
.input-group input {
height: 30px;
width: 93%;
padding: 5px 10px;
font-size: 16px;
border-radius: 5px;
border: 1px solid gray;
}
.btn {
padding: 10px;
font-size: 15px;
color: white;
background: #5F9EA0;
border: none;
border-radius: 5px;
}
.error {
width: 92%;
margin: 0px auto;
padding: 10px;
border: 1px solid #a94442;
color: #a94442;
background: #f2dede;
border-radius: 5px;
text-align: left;
}
.success {
color: #3c763d;
background: #dff0d8;
border: 1px solid #3c763d;
margin-bottom: 20px;
}
您可以嘗試兩種方法
更換你的線路
<link rel="stylesheet" type="text/css" href="style.css">
和
1:指向當前目錄
<link rel="stylesheet" type="text/css" href="./style.css">
2:從根目錄指向
<link rel="stylesheet" type="text/css" href="/registration/style.css">
因為您的 css 文件位於文件夾/registration/
中,而不是/registration/register.php/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.