JQuery Accordion:打开的 div 切入以满足内容(给出参考图像)

发布于 2024-08-19 21:02:58 字数 1053 浏览 4 评论 0原文

我会马上开始。这是我在标题中讨论的内容的图片:JQuery Accordion Bug。请注意 div 的轮廓如何切入右侧以符合我所选内容的内容。出于保密原因,我在 Paint 中屏蔽了 div 的内容,但您明白了。当我已经打开了另一项并尝试打开另一项时,就会发生这种情况。如果所有项目都关闭,并且我单击打开一个项目,它看起来不错(实际上,如果您仔细观察,它会切入然后快速正确地重新调整)。仅当一项已打开并且我单击另一项时才会发生此故障。下面是我用来设置手风琴的代码:

$('#demo_accordion').accordion({
    header: "h3",
    active: false,
    autoHeight: false,
    collapsible: true
});

请注意,collapsible 设置为 true,因此我一次只允许打开一个项目。现在,这是我正在使用的 html(以缩写形式):

<div id="demo_accordion">
    <% foreach (var entry in Entries) %>
    <% { %>
            <div>
                <h3><a href="#"><%= entry.EntryDate %> - Testing</a></h3>
                <table>
                    <!-- table code here -->
                </table>
            </div>
    <% } %>
</div>

我也在 <% 和 %> 中使用内联 .NET C#。不知道这是否与 CSS 相关或什么,但我很确定我完全按照在线演示进行操作。

任何帮助将不胜感激。谢谢。

I'll get right to it. Here's a pic of what I'm talking about in the title: JQuery Accordion Bug. Notice how the outline of the div cuts in on the right side to meet the content of what I've selected. I've blocked out the content of the div in Paint, for confidentiality reasons, but you get the idea. This happens when I already have another item opened, and try to open a different one. If all items are closed, and I click to open an item, it looks fine (actually, if you watch closely, it cuts in then re-adjusts correctly very fast). Only when one item is already open, and I click a different one does this glitch happen. Below is the code I'm using to set up the accordion:

$('#demo_accordion').accordion({
    header: "h3",
    active: false,
    autoHeight: false,
    collapsible: true
});

Notice that collapsible is set to true, so I'm only allowing one item to open at a time. Now, here is the html I'm using (in abbreviated form):

<div id="demo_accordion">
    <% foreach (var entry in Entries) %>
    <% { %>
            <div>
                <h3><a href="#"><%= entry.EntryDate %> - Testing</a></h3>
                <table>
                    <!-- table code here -->
                </table>
            </div>
    <% } %>
</div>

I'm using inline .NET C# as well, within the <% and %>. Don't know if it's something CSS related or what, but I'm pretty sure I'm following the demo's online exactly.

Any help would be appreciated. Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

难忘№最初的完美 2024-08-26 21:02:58

如果您查看 docs,它会为您提供手风琴的 html 格式。您想要的是更像这样的东西,其中表格位于块元素中,例如 div 并且该 div 位于标题之后。在每个手风琴部分周围都有一个封装 div 是不必要的。

格式应该是:

<div id="demo_accordion">
   <% foreach (var entry in Entries) %>
   <% { %>
      <h3><a href="#"><%= entry.EntryDate %> - Testing</a></h3>
      <div> 
         <table>
            <!-- table code here -->
         </table>
      </div>
   <% } %>
</div>

应该解决您的问题。

If you look at the docs, it gives you the html formatting for the accordion. What you want is something more like this where the table is in a block element, like a div and that div comes after the header. Having an encapsulating div around each accordion part is unnecessary.

Format should be:

<div id="demo_accordion">
   <% foreach (var entry in Entries) %>
   <% { %>
      <h3><a href="#"><%= entry.EntryDate %> - Testing</a></h3>
      <div> 
         <table>
            <!-- table code here -->
         </table>
      </div>
   <% } %>
</div>

Should solve your problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文