JQuery Accordion面板大小调整

时间:2014-12-16 01:09:24

标签: javascript jquery html css

我在这里收到了很多关于手风琴的帮助。结果,我认为一些代码已经被不同的成员改变了一些。我现在面临的一个大问题是Panel的1和1之间面板大小的差异。 2和Panel 3& 4.我是CSS和JQuery的新手,所以还不知道究竟出了什么问题。使用Panel的1& 2,面板不跨越标题的宽度。我正在使用Panel的3& 4但不是高度。我正在寻找所有4个面板中相同的一致性,我只是不肯定需要改变才能实现这一目标。感谢您的时间和任何可能提供的帮助。

这是工作示例:http://www.realtimehockey.net/scoresschedules/4579961481

FIDDLE:http://jsfiddle.net/Del087/3ewjtubd/

CSS

#accordion {
width:100%;
margin:10px auto;
border:1px solid black;
-webkit-box-shadow:0px 1px 3px rgba(0, 0, 0, 0.4);
-moz-box-shadow:0px 1px 3px rgba(0, 0, 0, 0.4);
box-shadow:0px 1px 3px rgba(0, 0, 0, 0.4);
}
#accordion h2 {
clear: both;
cursor:pointer;
margin:0px 0px;
padding:7px 15px;
border:1px solid white;
background-color:#080808;
font:bold 22px Petua One;
color:#ffffff;
text-shadow:0px 1px 0px rgba(0, 0, 0, 0.4);
}
#accordion .content1 {
background-color:#ffffff;
padding:10px 15px;
color:black;
height:230px;
width:25%;
float:left;
}
#accordion h2.active {
background-color:#ff6600;
}
.content-wrapper {
display: inline-block;
}
.content-wrapper a {
display: block;
}

HTML

<div id="accordion">
 <h2><a href="" target="_blank"><img src="http://i1314.photobucket.com/albums/t563/RTH13/RTH%20Artwork/RTHNeoLogo10_zps4b3f5604.png" width="25" height="25" border="0" alt=" photo RTHNeoLogo10_zps4b3f5604.png"/></a>   League Scores</h2>

<div class="content">
    <div class="content1"><a href="http://www.pahockey.com">Pittsburgh Amateur<br> Hockey League</a><a href="http://s1314.photobucket.com/user/RTH13/media/Association%20Logos/PAHL210210_zps694744b9.png.html" target="_blank"><img src="http://i1314.photobucket.com/albums/t563/RTH13/Association%20Logos/PAHL210210_zps694744b9.png" height="100" width="100" border="0" alt=" photo PAHL210210_zps694744b9.png"/></a>

        <br><a href="http://www.pahockey.com">Squirt</a>

        <br><a href="">Pee Wee</a>
        <br><a href="">Bantam</a>

    </div>
    <div class="content1"><a href="http://www.pahockey.com">High Performance<br> Hockey League</a>

        <br><a href="http://s1314.photobucket.com/user/RTH13/media/Association%20Logos/HPHL_zps31e66fcd.png.html" target="_blank"><img src="http://i1314.photobucket.com/albums/t563/RTH13/Association%20Logos/HPHL_zps31e66fcd.png" width="90" height="90" border="0" alt=" photo HPHL_zps31e66fcd.png"/></a>
        <br><a href="http://www.pahockey.com">Squirt</a>

        <br><a href="">Pee Wee</a>
        <br><a href="">Bantam</a>

    </div>
</div>
 <h2><a href="" target="_blank"><img src="http://i1314.photobucket.com/albums/t563/RTH13/RTH%20Artwork/RTHNeoLogo10_zps4b3f5604.png" width="25" height="25" border="0" alt=" photo RTHNeoLogo10_zps4b3f5604.png"/></a>   League Standings</h2>

<div class="content">
    <div class="content1">Pittsburgh Amateur Hockey League <a href="http://s1314.photobucket.com/user/RTH13/media/Association%20Logos/PAHL210210_zps694744b9.png.html" target="_blank"><img src="http://i1314.photobucket.com/albums/t563/RTH13/Association%20Logos/PAHL210210_zps694744b9.png" height="100" width="100" border="0" alt="Pittsburgh Amateur Hockey League - Pittsburgh, PA" title="Pittsburgh Amateur Hockey League - Pittsburgh, PA"/></a>

        <br><a href="http://www.pahockey.com">Squirt</a>
        <br>Pee Wee</div>
</div>
 <h2><a href="" target="_blank"><img src="http://i1314.photobucket.com/albums/t563/RTH13/RTH%20Artwork/RTHNeoLogo10_zps4b3f5604.png" width="25" height="25" border="0" alt=" photo RTHNeoLogo10_zps4b3f5604.png"/></a>   Tournament Scores</h2>

<div class="content">

    <div class="content-wrapper"><a href="http://s1314.photobucket.com/user/RTH13/media/bff3d1c7-f51d-42b7-98e4-240bfe796619_zpse0bc7d8e.jpg.html" target="_blank"><img src="http://i1314.photobucket.com/albums/t563/RTH13/bff3d1c7-f51d-42b7-98e4-240bfe796619_zpse0bc7d8e.jpg" height="100" width="100"  border="0"  alt="OneHockey - Laguna Hills, CA" title="OneHockey - Laguna Hills, CA"/></a>

    <br><a href="http://www.pahockey.com">Minnesota Gone Wild"</a>

    </div>
    <div class="content-wrapper"><a href="http://s1314.photobucket.com/user/RTH13/media/Banner%20Ads/NSTESLogo_zps7c937049.png.html" target="_blank"><img src="http://i1314.photobucket.com/albums/t563/RTH13/Banner%20Ads/NSTESLogo_zps7c937049.png" width="100 height="100" border="0" alt=" photo NSTESLogo_zps7c937049.png"/></a><a href="http://www.pahockey.com">Blizzard Challenge<br>Presidents Day Tournament</a>

    </div>
    <div class="content-wrapper"><a href="http://s1314.photobucket.com/user/RTH13/media/Banner%20Ads/NSTESLogo_zps7c937049.png.html" target="_blank"><img src="http://i1314.photobucket.com/albums/t563/RTH13/Banner%20Ads/NSTESLogo_zps7c937049.png" width="100 height="100" border="0" alt=" photo NSTESLogo_zps7c937049.png"/></a><a href="http://www.pahockey.com">Blizzard Challenge<br>Presidents Day Tournament</a>

    </div>
    <div class="content-wrapper"><a href="http://s1314.photobucket.com/user/RTH13/media/Banner%20Ads/NSTESLogo_zps7c937049.png.html" target="_blank"><img src="http://i1314.photobucket.com/albums/t563/RTH13/Banner%20Ads/NSTESLogo_zps7c937049.png" width="100 height="100" border="0" alt=" photo NSTESLogo_zps7c937049.png"/></a><a href="http://www.pahockey.com">Blizzard Challenge<br>Presidents Day Tournament</a>

    </div>

</div>
 <h2><a href="" target="_blank"><img src="http://i1314.photobucket.com/albums/t563/RTH13/RTH%20Artwork/RTHNeoLogo10_zps4b3f5604.png" width="25" height="25" border="0" alt=" photo RTHNeoLogo10_zps4b3f5604.png"/></a>   Tournament Standings</h2>

<div class="content">
    <div class="content-wrapper"><a href="http://s1314.photobucket.com/user/RTH13/media/bff3d1c7-f51d-42b7-98e4-240bfe796619_zpse0bc7d8e.jpg.html" target="_blank"><img src="http://i1314.photobucket.com/albums/t563/RTH13/bff3d1c7-f51d-42b7-98e4-240bfe796619_zpse0bc7d8e.jpg" height="100" width="100" border="0" alt="OneHockey - Laguna Hills, CA" title="OneHockey - Laguna Hills, CA"/></a><a href="http://www.pahockey.com">Minnesota Gone Wild<br>Texas Longhorn Shootout</a>

    </div>
    <div class="content-wrapper"><a href="http://s1314.photobucket.com/user/RTH13/media/Banner%20Ads/NSTESLogo_zps7c937049.png.html" target="_blank"><img src="http://i1314.photobucket.com/albums/t563/RTH13/Banner%20Ads/NSTESLogo_zps7c937049.png" width="100 height="100" border="0" alt=" photo NSTESLogo_zps7c937049.png"/></a><a href="http://www.pahockey.com">Blizzard Challenge<br>Presidents Day Tournament</a>

    </div>
    <div class="content-wrapper"><a href="http://s1314.photobucket.com/user/RTH13/media/Banner%20Ads/NSTESLogo_zps7c937049.png.html" target="_blank"><img src="http://i1314.photobucket.com/albums/t563/RTH13/Banner%20Ads/NSTESLogo_zps7c937049.png" width="100 height="100" border="0" alt=" photo NSTESLogo_zps7c937049.png"/></a><a href="http://www.pahockey.com">Blizzard Challenge<br>Presidents Day Tournament</a>

    </div>
</div>

JS

$(function () {
$('#accordion .content').hide();
//$('#accordion h2:first').addClass('active').next().slideDown('slow');
$('#accordion h2').click(function () {
    if ($(this).next().is(':hidden')) {
        $('#accordion h2').removeClass('active').next().slideUp('slow');
        $(this).toggleClass('active').next().slideDown('slow');
    }
});

});

1 个答案:

答案 0 :(得分:0)

关于身高,目前如下:

  1. 面板1的内容包含在类.content1的div中,此类的高度设置为230px,填充为10px到顶部和底部
  2. 面板2的内容包含在ID为#content1的div中,此id的高度也设置为230px,顶部和底部的填充也设置为10px
  3. 面板3和4的每个内容都包含在.content-wrapper类中,没有任何固定高度或填充集,因此内容恰好适合面板。
  4. 如果你是我希望使用相同的填充将所有面板设置为相同的230px高度,我刚刚在最新Fiddle

    中进行了调整