外部样式表不显示任何样式,但内部样式不会显示任何样式
问题描述:
当我将所有样式放在样式标签中时它工作正常,但如果我将这些代码放在外部样式表中,它不会在前端显示任何样式。外部样式表不显示任何样式,但内部样式不会显示任何样式
<!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文件*/
table{
width:1000px;
text-align:center;
margin:auto;
}
th{
background:#0CC;
animation-direction:normal;
height:50px;
}
td{
height:50px;
background:#396;
color:#FFF;
}
我DONOT明白什么是错的。
答
您的HTML <table>
应放置在<body></body>
之间。
答
嗯,为什么表头标记在头部?在那里你应该只放置元数据,脚本数据等等,据我所知/元标签,脚本标签,标题标签,链接到bootstrap例如/。你应该把你的餐桌标签放在身体部分,一切都应该没问题。请记住,头部的部分在您的网页上不可见,只有您放入身体的东西。希望能解决你的问题。 :)
答
试试这个:
<!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>
你可以试试这个在PHP? 'if(file_exists(“css/style.css”))echo“是”;'也许这是错误的路径?为了清楚起见,我希望在
和之间 – Andreas为什么你会在头部和身体之间张贴一张桌子?它在之后和
之前。你确定这是正确的吗? – Andreas@DSaha任何运气与答案? – Andreas