gpt4 book ai didi

php - 当表格由 PHP 函数构建时,是什么阻止表格使用 CSS 正确格式化?

转载 作者:行者123 更新时间:2023-11-28 14:28:36 26 4
gpt4 key购买 nike

我有一个在我的网络应用程序上动态构建的表格。行数和行内内容由一系列 PHP 函数决定。

一旦确定,他们就会调用另一组 PHP 函数来创建单独的表格行并包含类来定义它们的外观。尽管在我的应用程序的其他任何地方都有工作表,但我无法弄清楚为什么我无法获得适用于该表的标准和格式。输出已排序到表格中,但我无法更改字体大小、最小宽度、背景颜色或任何内容。

如果有人能指出我的问题,那将不胜感激!

这是确定结构的 PHP 函数:

// Determines the core number of buckets and the appropriate general structure for tree
function drawFullTree ($hyp, $b_count, $sb_count, $b, $sb)
{
// loop through *all* buckets
// if any bucket has no-sub buckets, put three (blanks) in it
for($i = 0; $i < $b_count; $i++){
if(!isset($sb[$i])){
$sb[$i][0] = '(blank)';
$sb[$i][1] = '(blank)';
$sb[$i][2] = '(blank)';
}
}

echo '<table class="answer">';
if($b_count > 0){
if(isset($sb[0])){
drawBuc_Sub($b[0], $sb[0]);
}
else{
echo 'sub-bucket blank';
}
}
if($b_count == 0){
echo 'What! No buckets - lets turn up the effort here!';
}
else if($b_count == 1){
echo "One bucket! Ok, it's a start... keep 'em coming";
}
else if($b_count == 2){
drawTop_Hyp_Buc_Sub($hyp, $b[1], $sb[1]);
}
else if($b_count == 3){
drawHyp_Buc_Sub($hyp, $b[1], $sb[1]);
drawBuc_Sub($b[2], $sb[2]);
}
else if($b_count == 4){
drawBuc_Sub($b[1],$sb[1]);
writeHyp($hyp);
drawBuc_Sub($b[2],$sb[2]);
drawBuc_Sub($b[3],$sb[3]);
}
else if($b_count == 5){
drawBuc_Sub($b[1],$sb[1]);
drawHyp_Buc_Sub($hyp, $b[2],$sb[2]);
drawBuc_Sub($b[3],$sb[3]);
drawBuc_Sub($b[4],$sb[4]);
}
else if($b_count == 6){
drawBuc_Sub($b[1],$sb[1]);
drawBuc_Sub($b[2],$sb[2]);
writeHyp($hyp);
drawBuc_Sub($b[3],$sb[3]);
drawBuc_Sub($b[4],$sb[4]);
drawBuc_Sub($b[5],$sb[5]);
}
echo '</table>';
}

这是我无法正确应用格式的 PHP 函数示例:

function writeHyp_Buc_Sub ($hyp, $buc, $sub)
{
echo '<tr>';
echo '<td class="x">' . $hyp . '</td>';
echo '<td class="x">' . $buc . '</td>';
echo '<td class="x">' . $sub . '</td>';
echo '</tr>';
}

这是我的 CSS:

table{
border-collapse: collapse;
}


td
{
font-size:.80em;
color: #333333;
padding: 6px 4px;
text-align:left;
/*border-bottom: 1px dotted #cccccc;*/
}

table.answer{
background-color:green;
border:3px black;
}

td.x
{
width:230px;
font-size:1.1em;
border:2px solid black; /*#DCDCDC; */
}

调用 php 函数并将其插入页面的 jquery:

    $('#process_structure').live('click', function () {
var postData = $('#inputs_structure').serializeArray();
postData.push({name: 'count', value: count});
$('#testing').fadeOut('slow');
$.ajax ({
type: "POST",
url: "structure_process.php",
data: $.param(postData),
success: function(text){
$('#testing').fadeIn('500', function(){
$('#testing').html(text);
})
}
});

$(this).parent().html('<form action="structure.php"><button class="begin_mod_button">Do another!</button></form>');

clearInterval(interval);
return false;
});

最佳答案

你的css是在html文档的头部吗?如果不是,那可能是问题所在...如果您使用的是 IE<=7(也可能是更新版本),我很确定这就是解决方案。 IE 仅在页面加载时呈现 css...如果 css 不在 head 部分,则内联 css 不会应用于插入到 dom 中的新事物。

因为 php 是函数,我猜它们会输出正确的 html(您可能在别处使用它们)。所以唯一可能出错的地方(考虑到上面的陈述)是你的 html/css“绑定(bind)”。

关于php - 当表格由 PHP 函数构建时,是什么阻止表格使用 CSS 正确格式化?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7629198/

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