2009-01-23 29 views
1

我有下面的CSS代码:CSS DIV不被认可

#Layer3 

{ 
position:absolute; 
width: 89%; 
height: 40%; 
left: 10%; 
top: 56%; 
background-color: #f1ffff; 
} 

#Layer3 h1 
{ 
font-size: medium; 
color: #000033; 
text-decoration: none; 
text-align: center; 
} 

.tableheader { 
    border-width:10px; border-style:solid; 
} 
.tablecontent { 
    height: 95%;  
    overflow:auto;  
} 

然而,当我使用这个PHP生成HTML

echo '<div id="tableheader" class="tableheader">'; 

echo "<h1>{$query} Auctions</h1>" . "\n"; 
echo "</div>"; 
echo '<div id="tablecontent" class="tablecontent">'; 

echo "<table border='0' width='100%'><tr>" . "\n"; 

echo "<td width='15%'>Seller ID</td>" . "\n"; 

echo "<td width='10%'>Start Date</td>" . "\n"; 

echo "<td width='75%'>Description</td>" . "\n"; 

echo "</tr>\n"; 

// printing table rows 

    foreach ($rows as $row) 

    { 

     $pk = $row['ARTICLE_NO']; 

     echo '<tr>' . "\n"; 

table contens generated in here 

     echo '</tr>' . "\n"; 

    } 
echo "</table>"; 
} 

echo "</div>"; 

产生这个网站:

<div id="tableheader" class="tableheader"> 
<h1>hardy Auctions</h1> 
</div> 
<div id="tablecontent" class="tablecontent"> 
<table border='0' width='100%'> 
<tr> 
<td width='15%'>Seller ID</td> 
<td width='10%'>Start Date</td> 
<td width='75%'>Description</td> 
the rest of table stuff 
</div> 

样式表被正确引用,所以我不确定是什么导致了错误。但是,根本不存在任何边框。这两个图层都在Layer3中,不再在页面上正确显示。

+0

你可以发布你创建的所有(相关的)HTML,即包括Layer3吗?因为如果我只从你的帖子中取得你的CSS和HTML,它会在各种浏览器中完美地显示边框...... – ISW 2009-01-23 15:48:01

回答

1
#tableheader { 
    border: 10px solid #000; 
} 

试着给它一个颜色。

编辑:由于它的id是tableheader,请尝试将样式选择器更改为id。你也可以尝试使用!很重要,看看是否有什么重写你的类选择器。

特异性值:

inline:1000; id:100,class:10,element:1

!重要的胜过所有其他非重要的声明。

+0

我给了它一种颜色,它不能解决任何问题。 – 2009-01-23 15:38:42

1

通过在Firefox中使用Firebug或使用IE中的IE开发工具栏浏览渲染页面中的HTML DOM开始。

这样,您就可以看到呈现页面中的元素实际上与哪些样式相关联。从那里调试问题要容易得多。

一种可能性是CSS文件中的某处存在语法错误,导致样式无法正确应用。

+0

另外检查萤火虫下的净选项卡,看看你的CSS文件是否真的加载 – bchhun 2009-01-23 17:15:38

0

我刚刚看了一下这个,它接缝很好,我也创建了这些的本地副本,并且样式工作也没问题,我在h1文本周围有一个很好的黑色边框。

所以,从你的解释是覆盖样式,或者样式没有被应用到页面。

+0

我得到它的工作,我需要位置:绝对在tableheader中,我不知道为什么 – 2009-01-26 11:09:51