当我将所有样式放在样式标记中时,它工作正常但如果我将这些代码放在外部样式表中,则它不会在前端显示任何样式。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php $title; ?></title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
</head>
<table border="1" cellpadding="2" cellspacing="2">
<tr>
<th>post ID</th>
<th>post title</th>
<th>post Description</th>
<th>Author</th>
<th>Date</th>
</tr>
<?php
foreach($posts as $post)
{
echo "
<tr>
<td>".$post->Post_id."</td>
<td>".$post->post_title."</td>
<td>".$post->Post_description."</td>
<td>".$post->author."</td>
<td>".$post->date."</td>
</tr>
" ;
}
?>
</table>
<body>
</body>
</html>
我的外部样式表是 / * CSS Document * /
table{
width:1000px;
text-align:center;
margin:auto;
}
th{
background:#0CC;
animation-direction:normal;
height:50px;
}
td{
height:50px;
background:#396;
color:#FFF;
}
我不明白什么是错的。
答案 0 :(得分:0)
您的HTML <table>
应放在<body></body>
。
答案 1 :(得分:0)
答案 2 :(得分:0)
试试这个:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php $title; ?></title>
<link href="../css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table border="1" cellpadding="2" cellspacing="2">
<tr>
<th>post ID</th>
<th>post title</th>
<th>post Description</th>
<th>Author</th>
<th>Date</th>
</tr>
<?php
foreach($posts as $post)
{
echo "
<tr>
<td>".$post->Post_id."</td>
<td>".$post->post_title."</td>
<td>".$post->Post_description."</td>
<td>".$post->author."</td>
<td>".$post->date."</td>
</tr>
" ;
}
?>
</table>
</body>
</html>