Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS Create an Accordion Menu with CSS

Create an Accordion Menu with CSS8:51 with David Conner

Hi

I tried to create this one my site i can get the text to drop down not sure what the issue is? http://www.vestedutility.com.au/home_safety_check.php

Please post a copy of your code.

David Conner
David Conner
Treehouse Guest Teacher

I am not seeing anything styled off the :checked psuedo-class. If you post your code. It may be easier to help you.

<div class="tab-group"> <div class="tab"> <input id="tab-one" type="radio" name="tabs"> <label for="tab-one"> MENU </label>
<div class="tab-content"> <p> this is where we put our header once if work out how to use css to do that!jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj </p>

      </div>
     </div>
    </div>
    <div class="tab-group">
 <div class="tab">
  <input id="tab-two" type="radio" name="tabs">
   <label for="tab-two">  MENU  </label>  
    <div class="tab-content"> 
    <p> this is where we put our header once if work out how to use css to do that!

      </div>
     </div>
    </div>
.tab-group{
    margin: 0 auto;
    max-width:40em;
    width:100%;
}

.tab{
    position:relative;
    width: 100%;
}

/*.tab input {
    position:absolute;
    left:0;
    top:0;
    z-index:-999;
}*/

.tab label {
    background: teal;
    color: white;
    display:block;
    font-weight:bold;
    line-height: 3;
    padding-left: .5em;
    margin-bottom: .5em;
    transition: letter-spacing .55s;    
}

.tab input:focus + label,
.tab label:hover{
    background:blue;
    letter-spacing:1px;
    }

.tab-content{
    max-height:0;
    overflow:hidden;
    transition: all .35s;
}

.tab-content p{
    margin:1em 0;

.tab input:checked ~ .tab-content {
    max-hight:6.25em;
}

Edited to format code.

2 Answers

David Conner
STAFF
David Conner
Treehouse Guest Teacher

You still have typos and extra divs. The main reason it is not working is that max-height is misspelled in the :checked state. It is usually a small typo or stray div that is the cause of most issues. Make sure you triple check spelling of declarations when you have an issue.

Here is a link to a cleaned up version. http://jsfiddle.net/r5z9ja3g/

David Conner
STAFF
David Conner
Treehouse Guest Teacher

James Wrest

.tab-content p is missing the closing curly bracket. This may be the cause of your issue. It is right before you :checked declaration. Hope that helps

Hi, I've repaired that still no luck, do you have a copy of your code?

Hi, I've repaired that still no luck, do you have a copy of your code?