简体   繁体   English

JQuery Accordion面板大小

[英]JQuery Accordion panel sizing

I've received quite a bit of assistance with my Accordion here on SO. 我的手风琴在这里获得了很多帮助。 As a result, I think that some code has been changed around a bit by different members. 结果,我认为一些代码已经由不同的成员进行了一些更改。 My big problem right now is the difference in panel sizing between Panel's 1 & 2 and that of Panel's 3 & 4. I'm new to CSS and JQuery so don't quite yet have the knowledge to figure out exactly what is wrong. 我现在的大问题是Panel 1和2与Panel 3和4在面板大小上的差异。我是CSS和JQuery的新手,所以还没有足够的知识来弄清楚到底出了什么问题。 With Panel's 1 & 2, the panel's do not span the width of the headers. 对于面板的1和2,面板的宽度不超过标题的宽度。 I'm getting the width with Panel's 3 & 4 but, not the height. 我得到的面板3和4的宽度,但不是高度。 I'm looking for the same consistency in all 4 panels and I'm just not positive what needs to be changed to accomplish this. 我正在所有4个面板中寻找相同的一致性,但是我不太肯定需要进行哪些更改才能实现此目的。 Thanks for your time and any assistance you may be able to provide. 感谢您的宝贵时间,以及您可能会提供的任何帮助。

This is the working example: http://www.realtimehockey.net/scoresschedules/4579961481 这是工作示例: http : //www.realtimehockey.net/scoresschedules/4579961481

FIDDLE: http://jsfiddle.net/Del087/3ewjtubd/ 内容: 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');
    }
});

}); });

Regarding the height, currently it's as follows: 关于高度,目前如下:

  1. The content of panel 1 is wrapped in a div with the class .content1 , the height of this class is set to 230px with a padding of 10px to top and bottom 面板1的内容包装在一个类为.content1的div中,该类的高度设置为230px,顶部和底部的填充为10px
  2. The content of panel 2 is wrapped in a div with the id #content1 , and the height for this id is also set to 230px, and the padding to top and bottom also set to 10px 面板2的内容包装在一个ID为#content1的div中,该ID的高度也设置为230px,顶部和底部的填充也设置为10px
  3. Each content of panel 3 and 4 is wrapped in a class .content-wrapper without any fixed height or padding set, so the content just fits in the panel. 面板3和4的每个内容都包装在一个.content-wrapper类中,没有任何固定的高度或填充设置,因此内容仅适合面板。

If you eg would prefer to set all panels to the same height of 230px with the same padding, I've just adjusted this in the latest Fiddle 如果您希望将所有面板的高度设置为230px,填充相同,则我在最新的Fiddle中进行了调整

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

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