简体   繁体   English

Javascript手风琴不会扩展

[英]Javascript Accordion Doesnt Stay Expanded

On one of my pages for an ASP.NET/C# website I'm using a Javascript accordion to contain GridView controls that display information from a database. 在ASP.NET/C#网站的其中一页上,我正在使用Javascript手风琴包含显示数据库信息的GridView控件。 When I build the page and test it locally, I need to double-click the accordion for it to do anything, and it's really sketchy and usually wont even open at all. 当我构建页面并在本地对其进行测试时,我需要双击手风琴对其进行任何操作,它确实很粗略,通常甚至根本无法打开。 When I publish the website and go to my domain on IE or Chrome, it either wont open at all or it'll open for a few seconds and collapse. 当我发布网站并在IE或Chrome上进入我的域时,它要么根本无法打开,要么会打开几秒钟然后崩溃。 Anyone have an idea of why this might happen? 任何人都知道为什么会发生这种情况吗? This is the code: 这是代码:

html: 的HTML:

<button class="accordion">Cases</button>
<div class="panel">
<p>
  <asp:GridView ID="gvCases" runat="server" AutoGenerateColumns="False" CellPadding="4" DataKeyNames="CaseID" DataSourceID="sdsCases" ForeColor="#333333" GridLines="None" AllowSorting="True">
      <AlternatingRowStyle BackColor="White" />
      <Columns>
          <asp:BoundField DataField="CaseID" HeaderText="CaseID" ReadOnly="True" SortExpression="CaseID" />
          <asp:BoundField DataField="Brand" HeaderText="Brand" SortExpression="Brand" />
      </Columns>

  </asp:GridView>
  <asp:SqlDataSource ID="sdsCases" runat="server" ConnectionString="<%$ ConnectionStrings:HardwareConnectionString %>" SelectCommand="SELECT * FROM [Computer_Cases]"></asp:SqlDataSource>
</p>
</div>

css: CSS:

button.accordion {
background-color: #eee;
color: #444;
cursor: pointer;
padding: 18px;
width: 100%;
border: none;
text-align: left;
outline: none;
font-size: 15px;
transition: 0.4s;
}

button.accordion.active, button.accordion:hover {
background-color: #ddd;
}

button.accordion:after {
content: '\02795';
font-size: 13px;
color: #777;
float: right;
margin-left: 5px;
}

button.accordion.active:after {
content: "\2796";
}

div.panel {
padding: 0 18px;
background-color: white;
max-height: 0;
overflow: hidden;
transition: 0.6s ease-in-out;
opacity: 0;
}

div.panel.show {
opacity: 1;
max-height: 3000px;  
}

Have a look at the below fiddle. 看看下面的小提琴。

https://jsfiddle.net/varit05/4pxkfef5/ https://jsfiddle.net/varit05/4pxkfef5/

Your code is working fine. 您的代码运行正常。

Seems like there is some problem with the view inside the accordion. 似乎手风琴内部的视图存在问题。

CSS: CSS:

#mainsection {
    width:1200px;
    margin:0 auto;
    text-align: center;
}

#descriptionSection{
    font-size: 22px;
}

#leftSide{
    float: left;
    width: 230px;
    background-color: white;
    text-align: left;
}

#rightSide{
    float: right;
    width: 970px;
    background-color: white;
}

button.accordion {
background-color: #eee;
color: #444;
cursor: pointer;
padding: 18px;
width: 100%;
border: none;
text-align: left;
outline: none;
font-size: 15px;
transition: 0.4s;
}

button.accordion.active, button.accordion:hover {
     background-color: #ddd;
}

button.accordion:after {
    content: '\02795';
    font-size: 13px;
    color: #777;
    float: right;
    margin-left: 5px;
}

button.accordion.active:after {
    content: "\2796";
}

div.panel {
    padding: 0 18px;
    background-color: white;
    max-height: 0;
    overflow: hidden;
    transition: 0.6s ease-in-out;
    opacity: 0;
}

div.panel.show {
     opacity: 1;
     max-height: 3000px;  
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM