2012-12-13 57 views
0

我有以下的CSS爲我的錯誤的div:Div只在Firefox中不可見?

.side_error { 
width: 325px; 
position: absolute; 
top: 0; 
left: -335px; 
padding: 8px 0 0 0; 
text-align: right; 
color: #FF0000; 
display: block; 
} 

和我的表TD下面的CSS:

.main_form td { 
padding: 5px 0 5px 0; 
position: relative; 
} 

而我的HTML結構:

<table class="main_form" align="center"> 
<tbody> 
<tr><td class="title_area"><h2>Create an account</h2><span>(or <a href="#">Sign In</a>)</span></td></tr> 
<tr><td><div class="side_error">please enter your full name &gt;&gt;</div><input type="text" name="fullname" placeholder="Full Name" class="input"></td></tr> 
<tr><td><input type="text" name="email" placeholder="Email" class="input"></td></tr> 
<tr><td><input type="password" name="pass1" placeholder="Password" class="input"></td></tr> 
<tr><td><input type="password" name="pass2" placeholder="Repeat Password" class="input"></td></tr> 
<tr><td class="submit_area"><span><input type="checkbox" name="terms" value="yes" id="rm"><label for="rm"> I agree to <a href="#">**** Terms</a>.</label></span><input type="submit" name="submit" class="submit" value="Create Account"></td></tr> 
</tbody> 
</table> 

與股利類side_error似乎出現在每個瀏覽器中,究竟是如何我想要它,但在Firefox(版本17.0.1)它根本不顯示,即使我使用Firebug div div當懸停HTML代碼時,它不會變色,就像它根本不存在一樣。

任何想法?

+2

嘗試刪除左:-335px ;? –

+0

通過刪除「左」的div現在出現在表外,這是完全錯誤的,任何想法爲什麼我只有在Firefox中遇到麻煩? – Eric

+0

似乎Firefox是唯一一個尊重規範在這裏。如果你的元素是position:absolute,並且你設置了left:negative_value,那麼它將被放置在視口之外。 –

回答

2

重新組織你的CSS,看看這helps-

CSS-

.side_error 
{ 
    width: 325px; 
    position: relative; 
    top: 20px; 
    left: -327px; 
    padding: 8px 0 0 0; 
    text-align: right; 
    color: #FF0000; 
    display: inline-block; 
} 
.main_form td 
{ 
    position:relative; 
    padding: 5px 0 5px 0; 
} 
table 
{ 
    width:330px; 
}​ 

看到工作小提琴 - DEMO

+0

非常有趣,很有創意,它的作品,謝謝! – Eric

0

刪除left: -335px;position: absolute;嘗試使用right :10px;

或將額外div圍繞內容td和分配類:

<tr> 
    <td > 
    <div class="title_area"> 
     <h2> 
     Create an account</h2><span>(or <a href="#">Sign In</a>)</span></div> 
    </td> 
</tr> 
+0

通常我會這樣使用它,但我不想讓表格的內容移動,並且根據我的理解,這隻能用「position:absolute」來完成。 – Eric