2016-05-01 120 views
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> 
    <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明白什麼是錯的。

+1

你可以試試這個在PHP? 'if(file_exists(「css/style.css」))echo「是」;'也許這是錯誤的路徑?爲了清楚起見,我希望在和之間 – Andreas

+1

爲什麼你會在頭部和身體之間張貼一張桌子?它在之後和之前。你確定這是正確的嗎? – Andreas

+0

@DSaha任何運氣與答案? – Andreas

回答

0

您的HTML <table>應放置在<body></body>之間。

0

嗯,爲什麼表頭標記在頭部?在那裏你應該只放置元數據,腳本數據等等,據我所知/元標籤,腳本標籤,標題標籤,鏈接到bootstrap例如/。你應該把你的餐桌標籤放在身體部分,一切都應該沒問題。請記住,頭部的部分在您的網頁上不可見,只有您放入身體的東西。希望能解決你的問題。 :)

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>