2013-04-26 67 views
0

我總是訪問Stackoverflow尋找答案(很棒的資源),但這是我的第一個問題。Div渲染以上(不在其他頂部)Div

我有2個div我需要渲染1上方的其他。 應該很簡單,我已經做了很多次了。 我的問題是它呈現相反。 相反的: DIV1 DIV2 我越來越: DIV2 DIV1

一直拉我的頭髮了好幾個小時了。 Div1是一個jQuery跳轉菜單 Div2是一個jQuery的手風琴列表。 我通過顯示/隱藏方法顯示出來:

 $("a[id='faq_link']").click(function(){ 
     $("div[id='agent-buynow-form']").hide(); 
     $("div[id='mid-header']").hide(); 
     $("div[id='jump-menu']").hide(); 
     $("div[class='cat']").hide(); 
     $("div[id='cat-home']").hide(); 
     $("div[id='agent-page-header']").hide(); 
     $("div[id='agent-page-menu']").hide(); 
     $("div[id='agent-page-main']").hide(); 
     $("div[id='agent-page-commissions']").hide(); 
     $("div[id='agent-page-buycard']").hide(); 
     $("div[id='agent-page-buybulk']").hide(); 
     $("div[id='agent-page-newsletter']").hide(); 
     $("div[id='agent-page-offers']").hide(); 
     $("div[id='buynow-form']").hide(); 
     $("div[id='archive-list']").hide(); 

     $("div[id='jump-menu']").show(); 
     $("div[id='faq-list']").show(); 
     $('html, body').animate({ scrollTop: $('#faq-list')}, 'slow');   
//   alert("FAQ clicked"); 

     }); 

跳轉菜單:

<!-- Begin Jump Menu --> 
<div id="jump-menu" class="top"> 
<table align="left" border="1px" cellpadding="2" cellspacing="2"> 
<tr> 
    <td> 
    Categories 
</td> 
<td> 
    Current: 
</td> 
<td> 
<div id="selection"> 
<select name="jumpMenu" id="jumpMenu"> 
    <option value="#cat-home" selected="selected">Home</option> 
    <option value="#cat-dining">Dining</option> 
    <option value="#cat-shows">Shows</option> 
    <option value="#cat-tours">Tours</option> 
    <option value="#cat-nightlife">Nightlife</option> 
    <option value="#cat-shopping">Shopping</option> 
    <option value="#cat-attractions">Attractions</option> 
    <option value="#cat-golf">Golf</option> 
    <option value="#cat-transportation">Transportation</option> 
    <option value="#cat-spas">Spas</option> 
    <option value="#cat-sports">Sports</option> 
    <option value="#cat-events">Special Events</option> 
    <option value="#cat-weddings">Weddings</option> 

</select> 
</div> 
</td> 
</tr> 
</table> 
</div> 
<!-- End Jump Menu --> 

問題列表:

<!-- Begin FAQ list --> 
<div id="faq-list" style="display:none;"> 
<table> 
<tr> 
<td style="height:131px; line-height:15px; padding-left:5px; padding-right:5px;"> 
<div align="center"><B>--- FREQUENTLY ASKED QUESTIONS --- </B> </div> 

<div id="accordion"> 
    <content> 
    Does the ******* Card expire? 
    </content> 
    <div> 
    Yes, all ******* Cards are valid one year from the date of purchase. 
    </div> 

    <content> 
    How many places accept this card? 
    </content> 
    <div> 
    We currently have over 500 merchan 
    </div> 
    <content> 
    How do I use my card? 
</content> 
<div> 
    Simply present your *********** at 
</div> 
<content> 
    What if I am traveling to ******** and do not have time for a card to be mailed to me? 
</content> 
<div> 
    When purchasing your card simp  
</div> 
<content> 
    Do the discounts change or will they always be the same? 
</content> 
<div> 
    We are continually adding new 
</div> 
<content> 
    Can I buy more than one card? 
</content> 
<div> 
    Yes, you can buy as many ***** 
</div> 
<content> 
    If the card is lost or stolen, can it be replaced? 
</content> 
<div> 
    Lost or stolen cards less than one year old can be replaced for the cost of shipping. 
</div> 
<content> 
    What do I do when my card expires? 
</content> 
<div> 
    Unfortunately, each ***** only 
</div> 
<content> 
    How long is each offer valid? 
</content> 
<div> 
    The merchants that provides 
</div> 
<content> 
    Do I have to book things ahead of time? 
</content> 
<div> 
    You do not have to book in 
</div> 
<content> 
    Is there a customer service number people can call? 
</content> 
<div> 
    Yes, your card comes with our Customer service number. 
</div> 
<content> 
    Can locals use the card too? 
</content> 
<div> 
    Yes, locals are welcome to use the card as well. 
</div> 
<content> 
    Can I get a discount for my entire party? 
</content> 
<div> 
    For dinner reservations,  
</div> 
</div>  
</td> 
</tr> 
</table> 
</div> 
<!-- End FAQ --> 

我看不出有什麼異常或不尋常的在CSS中。

其他div似乎顯示在正確的順序。

任何想法?

THX

+0

是浮動的元素之一?是左還是右? – 2013-04-26 21:44:11

回答

0

如果事情都出現在錯誤的順序了,位置等,它很可能是一個CSS問題,但不包括它的難以分析。

通常情況下,如果您想要在其他div的頂部顯示div,您可以在div的絕對位置div內進行。

您可以找到「位置」的規格屬性在這裏:

http://www.w3.org/TR/CSS2/visuren.html#propdef-position

由於默認的是「位置:靜態」,您可能需要重寫,要得到你想要的功能。如果它們亂序顯示,可能是因爲使用了「浮動」。

但是,沒有CSS,這很難確定。 jQuery將繪製你告訴它的內容,但CSS控制它在哪裏繪製它。

+0

感謝大家的意見。我一直無法找到一個CSS問題。爲了解決這個問題,我將DIV 1的位置(在實際代碼中)移到了DIV 2,DIV 3等之上,並且工作正常。在我看來,在代碼中的div的位置應該不重要,但在這種情況下,它的確如此。我的意圖是能夠使用隱藏/顯示來將每個div轉移到不同的級別(在頁面上向上或向下)。 – cliff 2013-04-28 04:39:58

0

我知道jQuery UI的手風琴爲元素添加了一些浮動樣式,使其顯示在其他div上方。您可以用!重要或修改爲最小寬度爲您的第一次潛水,讓它正確顯示。

+0

這發生在其他div也不只是手風琴。 – cliff 2013-04-28 04:27:59