【问题标题】:CSS form border formatting inside PHP filePHP文件中的CSS表单边框格式
【发布时间】:2015-01-18 20:59:06
【问题描述】:

我正在尝试将一些 CSS 嵌入到我的 PHP 文件中。如何正确添加我的 CSS,以便每个调用的表单都呈现在黑色边框内?这是我到目前为止所尝试的。

 while ($ratings = mysql_fetch_array($q))
    {
        //This outputs the doctors's name
        echo "Doctor's name:" . $ratings['doctor_name'] ."<br />";

            // Retrieve the id of the doctor which was posted on
            $id = $_POST['id'];

            echo "<style> form { border-style: solid; border-color: #ffffff}"; 

            //This outputs a textarea for the user to submit comments

            echo "<b>Your Experience: </b>";
            echo "<form method='post' action='review_doctors.php'> 

                    <textarea name='body'></textarea>
                    <input type='submit' name='submit' value='Send'/>

                    <input type='hidden' name='id' value='$ratings[id]' />

                    </style>

                 </form>
                 ";


            echo "<br />";
}

【问题讨论】:

  • 为什么要将表单包装在样式标签中?样式标签应该只包含样式。
  • 然后您的样式标签在form 之前终止。这会杀死 HTML。

标签: php html css forms


【解决方案1】:

如 cmets 中所述:“样式标签应仅包含样式”。

?>
<style>
form {
    border: 3px solid black;
}
</style>
<?php
while ($ratings = mysql_fetch_array($q)) {
    echo "<form>...</form>"
}

如果您想重用样式,可以将它们放在自己的文件中,然后将它们包含在每个页面中:

?>
<link rel="stylesheet" type="text/css" href="/path/to/mystyle.css">
<?php
// ...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-27
    • 2011-10-05
    • 1970-01-01
    • 2011-05-06
    相关资源
    最近更新 更多