PHP 中的内联样式 [英] Inline Styling in PHP

查看:30
本文介绍了PHP 中的内联样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设计一个页面的样式,该页面的中间有 PHP,可与表格相呼应.我的 html 通过外部样式表居中,但 PHP 部分(表格不会居中)所以我认为设置样式的最佳方法是在 php 部分中的内联 css.任何帮助表示赞赏.

I am styling a page that has PHP in the middle that echos out a table. I have the html centered through an external style sheet but the PHP section(where the table is wont center) so I am thinking the best way to style this is for inline css in the php section. any help is appreciated.

// display data in table




echo "<table border='1'  cellpadding='2' class='footable mdl-data-table mdl-js-data-table mdl-data-table--selectable mdl-shadow--4dp full-width'>";

echo "<tr> <th>ID</th> <th>Administration Console</th> <th>Product Version</th> <th>Platform</th> <th>Database</th> <th>Owner</th> <th>Status</th> <th></th> <th></th></tr>";



// loop through results of database query, displaying them in the table

while($row = mysql_fetch_array( $result )) {



// echo out the contents of each row into a table

echo "<tr>";

echo '<th>' . $row['id'] . '</th>';

echo '<td><a href="'.$row['curl'].'">'.$row['curl'].'</a></td>';

echo '<td>' . $row['pversion'] . '</td>';

echo '<td>' . $row['platform'] . '</td>';

echo '<td>' . $row['dversion'] . '</td>';

echo '<td><a href="mailto:'.$row['email'].'">' . $row['email'].'</a></td>';

echo '<td>' . $row['status'] . '</td>';

echo '<td><a href="php/edit.php?id=' . $row['id'] . '">Edit</a></td>';

echo '<td><a onclick="javascript:confirmationDelete($(this));return false;" href="php/delete.php?id=' . $row['id'] . '"onclick="return confirm("Do you want to delete this?")">Delete</a></td>';

echo "</tr>";

}





// close table>

echo "</table>";

?> 

推荐答案

您可以使用它,但所有表格都将居中

You can use this but all tables will be centered

table {
    margin: 0 auto;
}

或者定义一个类来标识具体的表

or define a class to identify the specific table

table .customClass {
    margin: 0 auto;
}

<table border='1' cellpadding='2' class='customClass footable mdl-data-table mdl-js-data-table mdl-data-table--selectable mdl-shadow--4dp full-width'>

或者您可以尝试使用 align="center"

<table align="center" border='1' cellpadding='2' class='footable mdl-data-table mdl-js-data-table mdl-data-table--selectable mdl-shadow--4dp full-width'>

希望对您有所帮助.

这篇关于PHP 中的内联样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆