php php表格文本居中对齐
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19810815/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
php table text align center
提问by Shivesh Jaiswal
I want to align text in center under table but i dnt know how to do this Here is my code
我想在表格下方居中对齐文本,但我不知道该怎么做 这是我的代码
echo "<td>" . $row['Firstname'] ." ". $row['Lastname'] ."</td>";
echo "<td>" . $row['Marks'] . "</td>";
echo "<td>" . $row['percent'] . "</td>";
echo "<td>" . $row['Status'] . "</td>";
Kindly help me how to do this. i tried this but not working
请帮助我如何做到这一点。我试过这个但不工作
echo '<td tyle="text-align:center;">' . $row['enroll'] . '</td>';
回答by Sridhar R
In CSS
在 CSS 中
.Classname td{
text-align: center;
}
In Inline
内联
echo '<td style="text-align:center;">' . $row['enroll'] . '</td>';
Or
或者
echo '<td align="center">' . $row['enroll'] . '</td>';
回答by R R
i think you did typo there.replace tyle
with style
我想你在那里打错字了。替换tyle
为style
echo '<td style="text-align:center;">' . $row['enroll'] . '</td>';
or you can also try
或者你也可以试试
echo '<td align="center">' . $row['enroll'] . '</td>';
回答by Daniel Andrei Minc?
First, include this code to see the table borders <table border="1">
首先,包含此代码以查看表格边框 <table border="1">
Next, include this beforeyour </header>
tag if you got everything in an HTML Doctype:
接下来,如果您在 HTML Doctype 中获得了所有内容,请在您的</header>
标签之前包含它:
<style type="text/css">
table td {
text-align: center;
}
</style>
And your done.
你完成了。
回答by Wayne Whitty
Use CSS instead:
改用 CSS:
.tableClass td{
text-align: center;
}
Inline styles are annoying to try and maintain, especially if they're output using PHP.
尝试和维护内联样式很烦人,尤其是当它们使用 PHP 输出时。
回答by Roy M J
You can use : align
attribute for td
:
您可以将 :align
属性用于td
:
echo '<td align="center">' . $row['enroll'] . '</td>';
Cheers
干杯
回答by Jenz
Use css or inside code write as:
使用 css 或内部代码编写为:
echo '<td style='.'"'.'text-align:center'.';">' . $row['enroll'] . '</td>';
回答by user2959229
Your code didn't work because there is a typing error - missing sin style
您的代码无效,因为输入错误 -样式中缺少s
echo '<td tyle="text-align:center;">' . $row['enroll'] . '</td>';
should be
应该
echo '<td style="text-align:center;">' . $row['enroll'] . '</td>';
回答by Janaka Senanayake
php table text align center
php表格文本居中对齐
echo " < td align='center'>" . $row['enroll'] . "< /td>";
回声“<td align='center'>”。$row['enroll'] 。"< /td>";