gpt4 book ai didi

html - PHP 中的内联样式

转载 作者:太空宇宙 更新时间:2023-11-04 01:53:24 25 4
gpt4 key购买 nike

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

// 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>";

?>

最佳答案

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

table {
margin: 0 auto;
}

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

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

希望这对你有帮助。

关于html - PHP 中的内联样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43049108/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com