Very simple CSS accordion



 Αντιγραφή επικόλληση τον παρακάτω κώδικα:


 <style>
/* foulscode.blogspor.gr */
@import url(http://fonts.googleapis.com/css?family=Oswald:400,300,700|Montserrat:400,700|Droid+Serif:400,400italic,700,700italic);

*{
  margin: 0; border: 0;
}

html{
  -font-smoothing: antialiased;
  height: 100%;
    background: white;
    background: radial-gradient(circle, #fff 20%, #ccc);
    background-size: cover;
}

h1{
  font-weight: lighter;
  margin: 0 auto;
  text-align: center;
  margin-top: 20%
}
p{
 
  font-family: 'Droid Serif';
  font-style: italic;
  color: #666;
  text-align: center;
  margin-top: 1%
}

Body{
  font-family: 'Montserrat';
}

#container{
  width: 400px;
  height: auto;
  margin: 0 auto;
  margin-top: 3%;
  border-top: 1px solid #bdbdbd;
  border-left: 1px solid #bdbdbd;
  border-right: 1px solid #bdbdbd;
}

.accordion label{
  display:block;
  background-color: #eeeeee;
  padding: 10px;
  color: #424242;
  text-shadow: 0 0 2px rgba(255,255,255,0.6);
  cursor: pointer;
  border-bottom: 1px solid #bdbdbd;
  border-top: 1px solid #ffffff;
}

.accordion p{
  color: #424242;
  padding: 10px;
  font-size: 0.8em;
  line-height: 1.7em;
  border-bottom: 1px solid #bdbdbd;
  font-family: 'Droid Serif';
  font-style: italic;
  visibility: hidden;
  opacity: 0;
  display: none;
  text-align: left;
  background-color: #fff;
  margin-top: 0px;
}

#tm:checked ~ .hiddentext{
  display: block;
  visibility: visible;
  opacity: 1;
}

input#tm{
  display: none;
  position: relative;
}

#tn:checked ~ .hiddentext{
  display: block;
  visibility: visible;
  opacity: 1;
}

input#tn{
  display: none;
  position: relative;
}

#to:checked ~ .hiddentext{
  display: block;
  visibility: visible;
  opacity: 1;
}

input#to{
  display: none;
  position: relative;
}
.arrow{
  color: #666666;
}
/* foulscode.blogspot.gr */
</style>
<h1>Very simple CSS3 accordion</h1>
<p>only by foulscode.blogspot.gr</p>
<!-- Start of the accordion -->
<div id="container">
  <!-- Item 1 -->
  <div class="accordion">
    <label for="tm" class="accordionitem"><h2>Item 1 <span class="arrow">&raquo;</span></h2></label>
    <input type="checkbox" id="tm"/>
    <p class="hiddentext">One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed  into a horrible vermin. He lay on his armour-like back, and if he lifted his head a little he could see his brown belly, slightly domed and divided by arches into stiff sections.</p>
  </div>
 
  <!-- Item 2 -->
  <div class="accordion">
    <label for="tn" class="accordionitem"><h2>Item 2 <span class="arrow">&raquo;</span></h2></label>
    <input type="checkbox" id="tn"/>
    <p class="hiddentext">One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin. He lay on his armour-like back, and if he lifted his head a little he could see his brown belly, slightly domed and divided by arches into stiff sections.</p>
  </div>
 
  <!-- Item 3 -->
  <div class="accordion">
    <label for="to" class="accordionitem"><h2>Item 3 <span class="arrow">&raquo;</span></h2></label>
    <input type="checkbox" id="to"/>
    <p class="hiddentext">One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin. He lay on his armour-like back, and if he lifted his head a little he could see his brown belly, slightly domed and divided by arches into stiff sections.</p>
  </div>
</div>


DEMO


Σχόλια