javascript - JS HTML CSS Accordion -


i'm looking use code have modified larger chunks of information. appears text cut off without padding. advice on how fix it?

here code. can see images on accordions end , text collides them.

    .container {   max-width: 960px;   margin: 0 auto;   padding: 2em 0 2em 0;     } 

//uses classlist, setattribute, , queryselectorall  //if want work in ie8/9 youll need polyfill these  (function() {    var d = document,      accordiontoggles = d.queryselectorall('.js-accordiontrigger'),      setaria,      setaccordionaria,      switchaccordion,      touchsupported = ('ontouchstart' in window),      pointersupported = ('pointerdown' in window);      skipclickdelay = function(e) {      e.preventdefault();      e.target.click();    }      setariaattr = function(el, ariatype, newproperty) {      el.setattribute(ariatype, newproperty);    };    setaccordionaria = function(el1, el2, expanded) {      switch (expanded) {        case "true":          setariaattr(el1, 'aria-expanded', 'true');          setariaattr(el2, 'aria-hidden', 'false');          break;        case "false":          setariaattr(el1, 'aria-expanded', 'false');          setariaattr(el2, 'aria-hidden', 'true');          break;        default:          break;      }    };    //function    switchaccordion = function(e) {      console.log("triggered");      e.preventdefault();      var thisanswer = e.target.parentnode.nextelementsibling;      var thisquestion = e.target;      if (thisanswer.classlist.contains('is-collapsed')) {        setaccordionaria(thisquestion, thisanswer, 'true');      } else {        setaccordionaria(thisquestion, thisanswer, 'false');      }      thisquestion.classlist.toggle('is-collapsed');      thisquestion.classlist.toggle('is-expanded');      thisanswer.classlist.toggle('is-collapsed');      thisanswer.classlist.toggle('is-expanded');        thisanswer.classlist.toggle('animatein');    };    (var = 0, len = accordiontoggles.length; < len; i++) {      if (touchsupported) {        accordiontoggles[i].addeventlistener('touchstart', skipclickdelay, false);      }      if (pointersupported) {        accordiontoggles[i].addeventlistener('pointerdown', skipclickdelay, false);      }      accordiontoggles[i].addeventlistener('click', switchaccordion, false);    }  })();
@import url(http://fonts.googleapis.com/css?family=lato:400,700);   * {    box-sizing: border-box;  }  body {    font-family: 'lato';  }  .heading-primary {    font-size: 2em;    padding: 2em;    text-align: center;  }  .accordion dl,  .accordion-list {    border: 1px solid #ddd;  }  .accordion dl:after,  .accordion-list:after {    content: "";    display: block;    height: 1em;    width: 100%;    background-color: #026453;  }  .accordion dd,  .accordion__panel {    /*text background */    background-color: #fff;    font-size: 1em;    line-height: 1.5em;  }  .accordion p {    padding: 1em 2em 1em 2em;  }  .accordion {    position: relative;    background-color: #fff;  }  .container {    max-width: 960px;    margin: 0 auto;    padding: 2em 0 2em 0;  }  .accordiontitle,  .accordion__heading {    background-image: url(960%20accordions/1.jpg);    text-align: center;    height: 83px;    font-weight: 700;    padding: 2em;    display: block;    text-decoration: none;    color: #fff;    -webkit-transition: background-color 0.5s ease-in-out;    transition: background-color 0.5s ease-in-out;    border-bottom: 1px solid #bc812a;  }  /* accordion 2 */    #accordion__heading2 {    background-image: url(960%20accordions/2.jpg);  }  #accordion__heading3 {    background-image: url(960%20accordions/3.jpg);  }  /*accordion 3 */    /*  .accordion__heading2 {    background-color: #363636;    text-align: center;    font-weight: 700;    padding: 2em;    display: block;    text-decoration: none;    color: #fff;    -webkit-transition: background-color 0.5s ease-in-out;    transition: background-color 0.5s ease-in-out;    border-bottom: 1px solid #30bb64;  }    .accordion__heading3 {    background-color: #121212;    text-align: center;    font-weight: 700;    padding: 2em;    display: block;    text-decoration: none;    color: #fff;    -webkit-transition: background-color 0.5s ease-in-out;    transition: background-color 0.5s ease-in-out;    border-bottom: 1px solid #30bb64;  }     */    .accordiontitle:before,  .accordion__heading:before {    content: "+";    font-size: 1.5em;    line-height: 0.5em;    float: left;    -webkit-transition: -webkit-transform 0.3s ease-in-out;    transition: -webkit-transform 0.3s ease-in-out;    transition: transform 0.3s ease-in-out;    transition: transform 0.3s ease-in-out, -webkit-transform 0.3s ease-in-out;  }  .accordiontitle:hover,  .accordion__heading:hover {    background-color: #006554;  }  .accordiontitleactive,  .accordiontitle.is-expanded {    background-color: #000;  }  .accordiontitleactive:before,  .accordiontitle.is-expanded:before {    -webkit-transform: rotate(-225deg);    transform: rotate(-225deg);  }  .accordionitem {    height: auto;    overflow: hidden;    max-height: 50em;    -webkit-transition: max-height 1s;    transition: max-height 1s;  }  @media screen , (min-width: 48em) {    .accordionitem {      max-height: 15em;      -webkit-transition: max-height 0.5s;      transition: max-height 0.5s;    }  }  .accordionitem.is-collapsed {    max-height: 0;  }  .no-js .accordionitem.is-collapsed {    max-height: auto;  }  .animatein {    -webkit-animation: accordionin 0.45s normal ease-in-out both 1;    animation: accordionin 0.45s normal ease-in-out both 1;  }  .animateout {    -webkit-animation: accordionout 0.45s alternate ease-in-out both 1;    animation: accordionout 0.45s alternate ease-in-out both 1;  }  @-webkit-keyframes accordionin {    0% {      opacity: 0;      -webkit-transform: scale(0.9) rotatex(-60deg);      transform: scale(0.9) rotatex(-60deg);      -webkit-transform-origin: 50% 0;      transform-origin: 50% 0;    }    100% {      opacity: 1;      -webkit-transform: scale(1);      transform: scale(1);    }  }  @keyframes accordionin {    0% {      opacity: 0;      -webkit-transform: scale(0.9) rotatex(-60deg);      transform: scale(0.9) rotatex(-60deg);      -webkit-transform-origin: 50% 0;      transform-origin: 50% 0;    }    100% {      opacity: 1;      -webkit-transform: scale(1);      transform: scale(1);    }  }  @-webkit-keyframes accordionout {    0% {      opacity: 1;      -webkit-transform: scale(1);      transform: scale(1);    }    100% {      opacity: 0;      -webkit-transform: scale(0.9) rotatex(-60deg);      transform: scale(0.9) rotatex(-60deg);    }  }  @keyframes accordionout {    0% {      opacity: 1;      -webkit-transform: scale(1);      transform: scale(1);    }    100% {      opacity: 0;      -webkit-transform: scale(0.9) rotatex(-60deg);      transform: scale(0.9) rotatex(-60deg);    }  }
<div class="container">    <h1 class="heading-primary">ssc on-boarding accordions</h1>    <div class="accordion">      <dl>        <dt>                  <a href="#accordion1" aria-expanded="false" aria-controls="accordion1" class="accordion-title accordiontitle js-accordiontrigger"> <!--first accordion heading-->  </a>                </dt>        <dd class="accordion-content accordionitem is-collapsed" id="accordion1" aria-hidden="true">          <p>lorem ipsum dolor sit amet, consectetur <a href="http://www.google.com">test</a>adipiscing elit. morbi eu interdum diam. donec interdum porttitor risus non bibendum. maecenas sollicitudin eros in quam imperdiet placerat. cras justo purus, rhoncus            nec lobortis ut, iaculis vel ipsum. donec dignissim arcu nec elit faucibus condimentum. donec facilisis consectetur enim sit amet varius. pellentesque justo dui, sodales quis luctus a, iaculis eget mauris.</p>          <p>aliquam dapibus, ante quis fringilla feugiat, mauris risus condimentum massa, @ elementum libero quam ac ligula. pellentesque @ rhoncus dolor. duis porttitor nibh ut lobortis aliquam. nullam eu dolor venenatis mauris placerat tristique eget            id dolor. quisque blandit adipiscing erat vitae dapibus. nulla aliquam magna nec elementum tincidunt.</p>        </dd>        <dt>                  <a href="#accordion2" aria-expanded="false" aria-controls="accordion2" id="accordion__heading2" class="accordion-title accordiontitle js-accordiontrigger">                    <!-- second accordion heading--></a>                </dt>        <dd class="accordion-content accordionitem is-collapsed" id="accordion2" aria-hidden="true">          <p>lorem ipsum dolor sit amet, consectetur adipiscing elit. morbi eu interdum diam. donec interdum porttitor risus non bibendum. maecenas sollicitudin eros in quam imperdiet placerat. cras justo purus, rhoncus nec lobortis ut, iaculis vel ipsum.            donec dignissim arcu nec elit faucibus condimentum. donec facilisis consectetur enim sit amet varius. pellentesque justo dui, sodales quis luctus a, iaculis eget mauris.</p>          <p>aliquam dapibus, ante quis fringilla feugiat, mauris risus condimentum massa, @ elementum libero quam ac ligula. pellentesque @ rhoncus dolor. duis porttitor nibh ut lobortis aliquam. nullam eu dolor venenatis mauris placerat tristique eget            id dolor. quisque blandit adipiscing erat vitae dapibus. nulla aliquam magna nec elementum tincidunt.</p>        </dd>        <dt>                  <a href="#accordion3" aria-expanded="false" aria-controls="accordion3" id="accordion__heading3" class="accordion-title accordiontitle js-accordiontrigger">                      <!--third accordion heading-->                  </a>                </dt>        <dd class="accordion-content accordionitem is-collapsed" id="accordion3" aria-hidden="true">          <p>lorem ipsum dolor sit amet, consectetur adipiscing elit. morbi eu interdum diam. donec interdum porttitor risus non bibendum. maecenas sollicitudin eros in quam imperdiet placerat. cras justo purus, rhoncus nec lobortis ut, iaculis vel ipsum.            donec dignissim arcu nec elit faucibus condimentum. donec facilisis consectetur enim sit amet varius. pellentesque justo dui, sodales quis luctus a, iaculis eget mauris.</p>          <p>aliquam dapibus, ante quis fringilla feugiat, mauris risus condimentum massa, @ elementum libero quam ac ligula. pellentesque @ rhoncus dolor. duis porttitor nibh ut lobortis aliquam. nullam eu dolor venenatis mauris placerat tristique eget            id dolor. quisque blandit adipiscing erat vitae dapibus. nulla aliquam magna nec elementum tincidunt.</p>        </dd>      </dl>    </div>  </div>

you can see jsfiddle here.

it's cutting off because have combination of overflow:hidden , max-height:15em on .accordionitem class. in order content show entirely, need rid of max-height:15em declaration.

//uses classlist, setattribute, , queryselectorall  //if want work in ie8/9 youll need polyfill these  (function() {    var d = document,      accordiontoggles = d.queryselectorall('.js-accordiontrigger'),      setaria,      setaccordionaria,      switchaccordion,      touchsupported = ('ontouchstart' in window),      pointersupported = ('pointerdown' in window);      skipclickdelay = function(e) {      e.preventdefault();      e.target.click();    }      setariaattr = function(el, ariatype, newproperty) {      el.setattribute(ariatype, newproperty);    };    setaccordionaria = function(el1, el2, expanded) {      switch (expanded) {        case "true":          setariaattr(el1, 'aria-expanded', 'true');          setariaattr(el2, 'aria-hidden', 'false');          break;        case "false":          setariaattr(el1, 'aria-expanded', 'false');          setariaattr(el2, 'aria-hidden', 'true');          break;        default:          break;      }    };    //function    switchaccordion = function(e) {      console.log("triggered");      e.preventdefault();      var thisanswer = e.target.parentnode.nextelementsibling;      var thisquestion = e.target;      if (thisanswer.classlist.contains('is-collapsed')) {        setaccordionaria(thisquestion, thisanswer, 'true');      } else {        setaccordionaria(thisquestion, thisanswer, 'false');      }      thisquestion.classlist.toggle('is-collapsed');      thisquestion.classlist.toggle('is-expanded');      thisanswer.classlist.toggle('is-collapsed');      thisanswer.classlist.toggle('is-expanded');        thisanswer.classlist.toggle('animatein');    };    (var = 0, len = accordiontoggles.length; < len; i++) {      if (touchsupported) {        accordiontoggles[i].addeventlistener('touchstart', skipclickdelay, false);      }      if (pointersupported) {        accordiontoggles[i].addeventlistener('pointerdown', skipclickdelay, false);      }      accordiontoggles[i].addeventlistener('click', switchaccordion, false);    }  })();
@import url(http://fonts.googleapis.com/css?family=lato:400,700);   * {    box-sizing: border-box;  }  body {    font-family: 'lato';  }  .heading-primary {    font-size: 2em;    padding: 2em;    text-align: center;  }  .accordion dl,  .accordion-list {    border: 1px solid #ddd;  }  .accordion dl:after,  .accordion-list:after {    content: "";    display: block;    height: 1em;    width: 100%;    background-color: #026453;  }  .accordion dd,  .accordion__panel {    /*text background */    background-color: #fff;    font-size: 1em;    line-height: 1.5em;  }  .accordion p {    padding: 1em 2em 1em 2em;  }  .accordion {    position: relative;    background-color: #fff;  }  .container {    max-width: 960px;    margin: 0 auto;    padding: 2em 0 2em 0;  }  .accordiontitle,  .accordion__heading {    background-image: url(960%20accordions/1.jpg);    text-align: center;    height: 83px;    font-weight: 700;    padding: 2em;    display: block;    text-decoration: none;    color: #fff;    -webkit-transition: background-color 0.5s ease-in-out;    transition: background-color 0.5s ease-in-out;    border-bottom: 1px solid #bc812a;  }  /* accordion 2 */    #accordion__heading2 {    background-image: url(960%20accordions/2.jpg);  }  #accordion__heading3 {    background-image: url(960%20accordions/3.jpg);  }  /*accordion 3 */    /*  .accordion__heading2 {    background-color: #363636;    text-align: center;    font-weight: 700;    padding: 2em;    display: block;    text-decoration: none;    color: #fff;    -webkit-transition: background-color 0.5s ease-in-out;    transition: background-color 0.5s ease-in-out;    border-bottom: 1px solid #30bb64;  }    .accordion__heading3 {    background-color: #121212;    text-align: center;    font-weight: 700;    padding: 2em;    display: block;    text-decoration: none;    color: #fff;    -webkit-transition: background-color 0.5s ease-in-out;    transition: background-color 0.5s ease-in-out;    border-bottom: 1px solid #30bb64;  }     */    .accordiontitle:before,  .accordion__heading:before {    content: "+";    font-size: 1.5em;    line-height: 0.5em;    float: left;    -webkit-transition: -webkit-transform 0.3s ease-in-out;    transition: -webkit-transform 0.3s ease-in-out;    transition: transform 0.3s ease-in-out;    transition: transform 0.3s ease-in-out, -webkit-transform 0.3s ease-in-out;  }  .accordiontitle:hover,  .accordion__heading:hover {    background-color: #006554;  }  .accordiontitleactive,  .accordiontitle.is-expanded {    background-color: #000;  }  .accordiontitleactive:before,  .accordiontitle.is-expanded:before {    -webkit-transform: rotate(-225deg);    transform: rotate(-225deg);  }  .accordionitem {    height: auto;    overflow: hidden;    max-height: 50em;    -webkit-transition: max-height 1s;    transition: max-height 1s;  }  @media screen , (min-width: 48em) {    .accordionitem {     /* max-height: 15em;*/      -webkit-transition: max-height 0.5s;      transition: max-height 0.5s;    }  }  .accordionitem.is-collapsed {    max-height: 0;  }  .no-js .accordionitem.is-collapsed {    max-height: auto;  }  .animatein {    -webkit-animation: accordionin 0.45s normal ease-in-out both 1;    animation: accordionin 0.45s normal ease-in-out both 1;  }  .animateout {    -webkit-animation: accordionout 0.45s alternate ease-in-out both 1;    animation: accordionout 0.45s alternate ease-in-out both 1;  }  @-webkit-keyframes accordionin {    0% {      opacity: 0;      -webkit-transform: scale(0.9) rotatex(-60deg);      transform: scale(0.9) rotatex(-60deg);      -webkit-transform-origin: 50% 0;      transform-origin: 50% 0;    }    100% {      opacity: 1;      -webkit-transform: scale(1);      transform: scale(1);    }  }  @keyframes accordionin {    0% {      opacity: 0;      -webkit-transform: scale(0.9) rotatex(-60deg);      transform: scale(0.9) rotatex(-60deg);      -webkit-transform-origin: 50% 0;      transform-origin: 50% 0;    }    100% {      opacity: 1;      -webkit-transform: scale(1);      transform: scale(1);    }  }  @-webkit-keyframes accordionout {    0% {      opacity: 1;      -webkit-transform: scale(1);      transform: scale(1);    }    100% {      opacity: 0;      -webkit-transform: scale(0.9) rotatex(-60deg);      transform: scale(0.9) rotatex(-60deg);    }  }  @keyframes accordionout {    0% {      opacity: 1;      -webkit-transform: scale(1);      transform: scale(1);    }    100% {      opacity: 0;      -webkit-transform: scale(0.9) rotatex(-60deg);      transform: scale(0.9) rotatex(-60deg);    }  }
<div class="container">    <h1 class="heading-primary">ssc on-boarding accordions</h1>    <div class="accordion">      <dl>        <dt>                  <a href="#accordion1" aria-expanded="false" aria-controls="accordion1" class="accordion-title accordiontitle js-accordiontrigger"> <!--first accordion heading-->  </a>                </dt>        <dd class="accordion-content accordionitem is-collapsed" id="accordion1" aria-hidden="true">          <p>lorem ipsum dolor sit amet, consectetur <a href="http://www.google.com">test</a>adipiscing elit. morbi eu interdum diam. donec interdum porttitor risus non bibendum. maecenas sollicitudin eros in quam imperdiet placerat. cras justo purus, rhoncus            nec lobortis ut, iaculis vel ipsum. donec dignissim arcu nec elit faucibus condimentum. donec facilisis consectetur enim sit amet varius. pellentesque justo dui, sodales quis luctus a, iaculis eget mauris.</p>          <p>aliquam dapibus, ante quis fringilla feugiat, mauris risus condimentum massa, @ elementum libero quam ac ligula. pellentesque @ rhoncus dolor. duis porttitor nibh ut lobortis aliquam. nullam eu dolor venenatis mauris placerat tristique eget            id dolor. quisque blandit adipiscing erat vitae dapibus. nulla aliquam magna nec elementum tincidunt.</p>        </dd>        <dt>                  <a href="#accordion2" aria-expanded="false" aria-controls="accordion2" id="accordion__heading2" class="accordion-title accordiontitle js-accordiontrigger">                    <!-- second accordion heading--></a>                </dt>        <dd class="accordion-content accordionitem is-collapsed" id="accordion2" aria-hidden="true">          <p>lorem ipsum dolor sit amet, consectetur adipiscing elit. morbi eu interdum diam. donec interdum porttitor risus non bibendum. maecenas sollicitudin eros in quam imperdiet placerat. cras justo purus, rhoncus nec lobortis ut, iaculis vel ipsum.            donec dignissim arcu nec elit faucibus condimentum. donec facilisis consectetur enim sit amet varius. pellentesque justo dui, sodales quis luctus a, iaculis eget mauris.</p>          <p>aliquam dapibus, ante quis fringilla feugiat, mauris risus condimentum massa, @ elementum libero quam ac ligula. pellentesque @ rhoncus dolor. duis porttitor nibh ut lobortis aliquam. nullam eu dolor venenatis mauris placerat tristique eget            id dolor. quisque blandit adipiscing erat vitae dapibus. nulla aliquam magna nec elementum tincidunt.</p>        </dd>        <dt>                  <a href="#accordion3" aria-expanded="false" aria-controls="accordion3" id="accordion__heading3" class="accordion-title accordiontitle js-accordiontrigger">                      <!--third accordion heading-->                  </a>                </dt>        <dd class="accordion-content accordionitem is-collapsed" id="accordion3" aria-hidden="true">          <p>lorem ipsum dolor sit amet, consectetur adipiscing elit. morbi eu interdum diam. donec interdum porttitor risus non bibendum. maecenas sollicitudin eros in quam imperdiet placerat. cras justo purus, rhoncus nec lobortis ut, iaculis vel ipsum.            donec dignissim arcu nec elit faucibus condimentum. donec facilisis consectetur enim sit amet varius. pellentesque justo dui, sodales quis luctus a, iaculis eget mauris.</p>          <p>aliquam dapibus, ante quis fringilla feugiat, mauris risus condimentum massa, @ elementum libero quam ac ligula. pellentesque @ rhoncus dolor. duis porttitor nibh ut lobortis aliquam. nullam eu dolor venenatis mauris placerat tristique eget            id dolor. quisque blandit adipiscing erat vitae dapibus. nulla aliquam magna nec elementum tincidunt.</p>        </dd>      </dl>    </div>  </div>


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -