html - 不一致的 CSS 表显示(使用 SQL 和 PHP)

标签 html css html-table

我遇到了一个问题,当我使用 PHP 和 HTML 从数据库中将信息回显到表中时,信息会根据它的加载方式移动。

我的意思是,如果我不断刷新,一切都会与以前不同。我的意思是它是如何显示的,而不是显示的内容。

.tracklist {

}
.tracklist img {
max-width:15%;
max-height:15%;
}
.tracklist td{
width:36%;
display:block;
padding:1%;
text-align:center;
}

#content {
width:98%;
height:73%;
padding-left:1%;
padding-right:1%;
background-color:#d8d8d8;
text-align:center;
}
#contentbox {
border-radius: 15px; 
-moz-border-radius: 15px; 
-webkit-border-radius: 15px; 
text-align:center;
background-color:#999999;
}

<div id="content">
<div id="contentbox">
<br />
<table class="tracklist">
<?php


        $i = 0; $trEnd = 0;
        while ($row = mysql_fetch_array($result)){
            if($i == 0){
                echo '<tr>';
            }
            echo '<td>';
                echo $row["genre"]." | ".$row["artist"]." | ".$row["name"];
                echo '<br />';
    echo "<img src=".$row["image"].' />';
        echo '</td>';
            if($i == 2){
                $i = 0; $trEnd = 1;
            }else{
                $trEnd = 0; $i++;
            }
            if($trEnd == 1) {
                echo '</tr>';
            }
        }
        if($trEnd == 0) echo '</tr>';

?>
</table>
</div>
</div>

来自数据库的数据在标题中被调用只是为了让人们知道它被调用了。

最佳答案

通过放置 width:100%; 来解决这个问题在它继承高度的类中。

现在似乎修复了它。

关于html - 不一致的 CSS 表显示(使用 SQL 和 PHP),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29014100/

相关文章:

java - 使用 colspan 和 rowspan 从二维数组生成 html 表

javascript - 在 slideToggle 调用期间需要更好的方法来保持 Fieldset 宽度

javascript - Jquery dotdotdot 仅在窗口调整大小时正确触发

javascript - 如何在页面上单击按钮时将 css 与原生 js 一起应用

php - 水平响应式布局

javascript - 自动溢出的可变高度

html - 如何让 td 占据 tr 的 50%

php - 文件夹内的 CodeIgniter、NGINX 不工作

html - 如何将溢出设置为隐藏以保护元素正确超出页脚?

javascript - 拖入 GIF 时表格变形