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. 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. Anyone have an idea of why this might happen? This is the code:
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:
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/
Your code is working fine.
Seems like there is some problem with the view inside the accordion.
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;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.