0

我一直访问 Stackoverflow 以获得答案(很好的资源),但这是我的第一个问题。

我有 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 似乎以正确的顺序显示。

有任何想法吗?

谢谢

4

2 回答 2

0

我知道 jQuery UI 的手风琴为元素添加了一些浮动样式,使其显示在其他 div 之上。要么用 !important 覆盖这些,要么在你的第一次潜水时修改 min-width 以使其正确显示。

于 2013-04-26T22:03:22.133 回答
0

如果事情以错误的顺序、位置等显示,很可能是 CSS 问题,但由于不包括在内,因此难以分析。

通常,如果您想在其他 div 之上显示 div,您可以在相对位置 div 内使用 div 的绝对定位来实现。

您可以在此处找到“位置”属性的规范:

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

由于默认值为“位置:静态”,因此您可能需要覆盖它以获得所需的功能。如果它们显示无序,则可能是使用了“浮动”的结果。

但同样,如果没有 CSS,这很难确定。jQuery 将绘制您告诉它的内容,但 CSS 控制它绘制的位置。

于 2013-04-26T21:57:25.620 回答