简体   繁体   English

外部样式表不显示任何样式,但内部样式表显示

[英]external stylesheet not showing any style but internal one does

when ever i am putting all the style in the style tag it is working fine but if i put those codes in an external stylesheet it is not showing any style in frontend. 每当我将所有样式都放在样式标签中时,它都可以正常工作,但是如果我将这些代码放入外部样式表中,则不会在前端显示任何样式。

<!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>

and my external stylesheet is /* CSS Document */ 而我的外部样式表是/ * CSS文档* /

table{
    width:1000px;
    text-align:center;
    margin:auto;
    }
th{
    background:#0CC;
    animation-direction:normal;
    height:50px;
    }
td{
    height:50px;
    background:#396;
    color:#FFF;
    }   

i donot understand what is wrong. 我不明白怎么了。

您的HTML <table>应该放在<body></body>

Ummm, why is the table tag in the head part? 嗯,为什么表标签在头部? There you should place only meta data, script data and all like, as far as I know / meta tags, script tags, title tag, link to bootstrap for example /. 据我所知,您应该仅在其中放置元数据,脚本数据和所有类似内容/元标记,脚本标记,标题标记,引导程序链接,例如/。 You should place your table tag in the body part and everything should be fine. 您应该将表格标签放在身体部位,一切都应该没问题。 Remember, the part in the head is NOT visible on you web page, only the things you put in the body. 请记住,头部的一部分在您的网页上不可见,只有您放在体内的东西可见。 Hope that fixes your problem. 希望能解决您的问题。 :) :)

Try this: 尝试这个:

<!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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM