应用CSS样式后,表格右侧对齐

时间:2015-11-06 07:41:04

标签: php css mysqli html-table

我做了一些CSS样式更改后,我的表现在与右侧对齐。 我尝试添加表align="center",但它也无效。 请让我知道我错过了什么。

enter image description here

table {
//font: 11px/24px Verdana, Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 320px;
}

th {
padding: 0 0.5em;
text-align: left;
}


td {
border-bottom: 1px solid #CCC;
padding: 0 0.5em;
}

td.width {
width: 190px;
}


<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Browse CD</title>
    <link rel="stylesheet" type="text/css" href="CDcss.css" />
</head>
<body>
    <div id="wrapper">
    <div id="banner">        
        </div>

        <nav id="navigation">
            <ul id="nav">
                <li><a href="index.php">Home</a></li>
                <li><a href="DisplayCD.php">Browse</a></li>
                <li><a href="SearchCD.php">Search</a></li>
                <li><a href="Credit.php">Credit</a></li>
            </ul>
        </nav>

 <style> 

 td, th {
 border: 1px solid black;
 }


 th {
 background-color: grey;
 color: white;
 }

 </style> 

 <?php
 header('Content-type: text/html; charset=iso-8859-1');

 include 'database_conn.php';   

$sql = "SELECT nmc_cd.CDID, nmc_cd.CDTitle, nmc_cd.CDYear, nmc_cd.CDPrice, nmc_category.catDesc, nmc_cd.catID
            FROM nmc_cd 
            LEFT JOIN nmc_category ON nmc_cd.catID=nmc_category.catID"; 

$queryresult = mysqli_query($conn, $sql)
or die (mysqli_error($conn));       

    echo '<table class=table>';
    echo '<tr><th>Music Title</th><th>Year</th><th>Price</th>  <th>Category</th><tr>'; 
    echo '</table';

while($row = mysqli_fetch_assoc($queryresult)) {
    $iCDID = $row['CDID'];
    $CDTitle = $row['CDTitle'];
            $CDYear = $row['CDYear'];
    $CDPrice = $row['CDPrice'];
            $CDCat = $row['catDesc'];
            $CDCatID = $row['catID'];

            echo "<table><tr><td>
            <a href = \"editCDForm.php?itemCode=$iCDID\">$CDTitle</a>
            </td><td> $CDYear
            </td><td> $CDPrice  
            </td><td> $CDCat
            </td></tr>
            </table";
}


mysqli_free_result($queryresult); 
mysqli_close($conn);
?>

</body>
</html>

1 个答案:

答案 0 :(得分:0)

提供您网站的链接或此表格所在的页面。