我的代码显示:
但我不确定我是否实现了div和输入表格的正确混合。
如果我以正确的方式这样做,请你评论一下吗?
CSS:
.newstuff
{
width: 80%;
height: 100px;
}
.newstuff.left
{
float: left;
padding-left: 5px;
text-align: right;
width: 15%;
vertical-align: middle;
background: red;
}
.newstuff.center
{
float: left;
padding-left: 5px;
text-align: left;
width: 35%;
vertical-align: middle;
background: green;
}
.newstuff.right
{
float: left;
padding-left: 5px;
text-align: left;
width: 35%;
vertical-align: middle;
background: yellow;
}
.buttontest
{
float: left;
width: 35%;
}
PHP:
<?php
echo "<head>";
echo ' <link rel="stylesheet" href="test.css">';
echo "</head>";
echo '<body>';
echo '<div class="newstuff">';
echo ' <form action="'.htmlspecialchars($_SERVER["PHP_SELF"]).'" method="post" name="auth_form">';
echo '<div class="newstuff left">';
echo ' <input type="text" name="data1" placeholder="This is left">';
echo '</div>';
echo '<div class="newstuff center">';
echo '<textarea name="centertext" rows="5" cols="50" maxlength="255" placeholder="This is center"></textarea>';
echo '</div>';
echo '<div class="newstuff right">';
echo ' <input type="text" name="data3" placeholder="This is right">';
echo '</div>';
echo '</div>';
echo '<div class="buttontest">';
echo ' <input type="submit" name="test" value="Testing">';
echo " </form>";
echo '</div>';
echo "</body>";
?>
答案 0 :(得分:3)
绝对不是合适的混合方式。
尝试使用PHP的模板引擎,以下是您可以选择的选项:
由于妥协(我不建议长期使用)是使用 Alternative syntax for control structures in PHP 和short tags,我认为这对于普通的模板。