我在將我的樣式錶鏈接到.php
文件中包含的我的網站的html
部分時出現問題。Llinking一個CSS文件不起作用
我不清楚,爲什麼樣式表的某些元素不工作,例如,如果我設置body
的background-color
紅色它將設置,但是如果我創建CSS文件中的div.header
元素,並嘗試將它添加到HTML文件中的元素<div id='header'>
,它什麼都不做。
這可能是什麼原因?我的CSS文件和.php
文件如下。
courses.css
:
h1{
font:bolder;
}
h3{
font-color:red;
}
body{
background-color:white;
}
div.header{
position:fixed;
margin-top: 1ex;
margin-bottom: 1ex;
background-color: red;
}
div.Select_Course{
position:relative;
right:2ex;
top:4ex;
border:solid thin black;
padding: 5ex;
margin-bottom:3ex;
height:relative;
}
和我.php
文件
<meta charset="UTF-8">
<?php
$mysqli = new mysqli('localhost', 'user', 'password','dbname');
if ($mysqli->connect_errno)
{
die('Database connection failed');
}
//$m->set_charset('utf8');
$search_course = "
SELECT title, summary, id
FROM course
WHERE title LIKE '%".$_POST['searchBar']."%'";
$result = $mysqli->query($search_course) or die($mysqli->error);
$search_result = $result->fetch_assoc();
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link rel='stylesheet' href='courses.css'>
<div id='header'>
<h1>Search Results</h1>
</div>
</head>
<body>
<?php while($search_result = $result->fetch_assoc()) { ?>
<div id='Select_Course'>
<form name="searchresults" method="post" action="selectedcourse.php">
<h3><?= $search_result['title'] ?> <input name="searchforcourse" type="submit" value="View Course" /></h3>
<input name="Coursenamesearch" type="text" value="<?= $search_result['title'] ?>" hidden/>
</form>
<p><?= $search_result['summary'] ?></p>
</div>
<?php } ?>
</body>
</html>
頭格應下
標籤。 –'div#header'如何? – miken32