Team:KIT-Kyoto/Notebook-week11
From 2010.igem.org
Line 58: | Line 58: | ||
</head> | </head> | ||
- | <body> | + | <body> |
- | + | <h1 style="text-align:center">Accordion with color transition example - solutoire.com</h1> | |
- | + | <p style="width: 400px; margin:10px auto"> | |
- | + | See the 'Javascript used in this example' tab for the options used in this example. | |
+ | </p> | ||
<p class="accToggler">Click me!</p> | <p class="accToggler">Click me!</p> | ||
<p class="accContent"> | <p class="accContent"> | ||
- | + | Lorem ipsum dolor sit amet, consectetuer adipiscing elit. In eu elit. Sed consequat neque et sapien. In hac habitasse platea dictumst. In hac habitasse platea | |
- | + | dictumst. Donec justo dui, aliquam ac, feugiat nec, malesuada ac, enim. Etiam consequat nulla eget metus malesuada tincidunt. Ut ultrices nonummy metus. | |
- | + | Pellentesque pharetra neque eu urna. In nec ligula. Curabitur purus ligula, consectetuer id, auctor et, gravida pretium, est. Aenean vitae neque. Integer dolor | |
- | </p> | + | enim, ultricies semper, ullamcorper at, mollis at, mauris. |
- | + | </p> | |
- | <p class="accToggler">Click me!</p> | + | <p class="accToggler">Click me!</p> |
+ | <p class="accContent"> | ||
+ | Lorem ipsum dolor sit amet, consectetuer adipiscing elit. In eu elit. Sed consequat neque et sapien. In hac habitasse platea dictumst. In hac habitasse platea | ||
+ | dictumst. Donec justo dui, aliquam ac, feugiat nec, malesuada ac, enim. Etiam consequat nulla eget metus malesuada tincidunt. Ut ultrices nonummy metus. | ||
+ | Pellentesque pharetra neque eu urna. In nec ligula. Curabitur purus ligula, consectetuer id, auctor et, gravida pretium, est. Aenean vitae neque. Integer dolor | ||
+ | enim, ultricies semper, ullamcorper at, mollis at, mauris. | ||
+ | </p> | ||
+ | |||
+ | <p class="accToggler">Javascript used in this example</p> | ||
+ | <p class="accContent"> | ||
+ | <code> | ||
+ | var accordion;<br /> | ||
+ | var accordionTogglers;<br /> | ||
+ | var accordionContents;<br /><br /> | ||
+ | |||
+ | window.onload = function() {<br /><br /> | ||
+ | accordionTogglers = document.getElementsByClassName('accToggler');<br /><br /> | ||
+ | |||
+ | accordionTogglers.each(function(toggler){<br /> | ||
+ | //remember the original color<br /> | ||
+ | toggler.origColor = toggler.getStyle('background-color');<br /> | ||
+ | //set the effect<br /> | ||
+ | toggler.fx = new Fx.Color(toggler, 'background-color');<br /> | ||
+ | });<br /><br /> | ||
+ | |||
+ | accordionContents = document.getElementsByClassName('accContent');<br /><br /> | ||
+ | accordion = new Fx.Accordion(accordionTogglers, <br /> | ||
+ | accordionContents,{<br /> | ||
+ | //when an element is opened change the<br /> | ||
+ | //background color to blue<br /> | ||
+ | onActive: function(toggler){<br /> | ||
+ | toggler.fx.toColor('#6899CE');<br /> | ||
+ | },<br /> | ||
+ | onBackground: function(toggler){<br /> | ||
+ | //change the background color to the original (green)<br /> | ||
+ | //color when another toggler is pressed<br /> | ||
+ | toggler.setStyle('background-color', toggler.origColor);<br /> | ||
+ | }<br /> | ||
+ | });<br /> | ||
+ | } | ||
+ | </code> | ||
+ | </p> | ||
+ | <p class="accToggler">CSS used in this example</p> | ||
<p class="accContent"> | <p class="accContent"> | ||
- | + | <code> | |
- | + | .accToggler{<br /> | |
- | + | margin: 3px auto;<br /> | |
- | < | + | padding: 3px;<br /> |
- | + | width: 400px;<br /> | |
- | + | background: #acc95f;<br /> | |
- | + | color: #f4f4f4;<br /> | |
- | + | border: 1px solid #fff;<br /> | |
- | + | cursor: pointer;<br /> | |
- | + | }<br /><br /> | |
- | + | .accContent{<br /> | |
- | + | margin: 0px auto;<br /> | |
- | + | width: 400px;<br /> | |
- | + | }<code> | |
- | + | </p> | |
- | + | <p style="width: 400px; margin:10px auto;text-align:center"> | |
- | + | ©2006 <b><a href="http://www.solutoire.com">solutoire.com</a></b> | |
- | : | + | </p> |
- | : | + | </body> |
- | < | + | </html> |
- | + | ||
- | < | + | |
- | : | + | |
- | : | + | |
- | + | ||
- | + | ||
- | + | ||
- | :: | + | |
- | : | + | |
- | < | + | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | : | + | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | </p> | + | |
- | + | ||
- | + | ||
- | < | + | |
- | + | ||
- | + | ||
- | + |
Revision as of 14:00, 6 September 2010
Accordion with color transition example - solutoire.com
See the 'Javascript used in this example' tab for the options used in this example.
Click me!
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. In eu elit. Sed consequat neque et sapien. In hac habitasse platea dictumst. In hac habitasse platea dictumst. Donec justo dui, aliquam ac, feugiat nec, malesuada ac, enim. Etiam consequat nulla eget metus malesuada tincidunt. Ut ultrices nonummy metus. Pellentesque pharetra neque eu urna. In nec ligula. Curabitur purus ligula, consectetuer id, auctor et, gravida pretium, est. Aenean vitae neque. Integer dolor enim, ultricies semper, ullamcorper at, mollis at, mauris.
Click me!
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. In eu elit. Sed consequat neque et sapien. In hac habitasse platea dictumst. In hac habitasse platea dictumst. Donec justo dui, aliquam ac, feugiat nec, malesuada ac, enim. Etiam consequat nulla eget metus malesuada tincidunt. Ut ultrices nonummy metus. Pellentesque pharetra neque eu urna. In nec ligula. Curabitur purus ligula, consectetuer id, auctor et, gravida pretium, est. Aenean vitae neque. Integer dolor enim, ultricies semper, ullamcorper at, mollis at, mauris.
Javascript used in this example
var accordion;
var accordionTogglers;
var accordionContents;
window.onload = function() {
accordionTogglers = document.getElementsByClassName('accToggler');
accordionTogglers.each(function(toggler){
//remember the original color
toggler.origColor = toggler.getStyle('background-color');
//set the effect
toggler.fx = new Fx.Color(toggler, 'background-color');
});
accordionContents = document.getElementsByClassName('accContent');
accordion = new Fx.Accordion(accordionTogglers,
accordionContents,{
//when an element is opened change the
//background color to blue
onActive: function(toggler){
toggler.fx.toColor('#6899CE');
},
onBackground: function(toggler){
//change the background color to the original (green)
//color when another toggler is pressed
toggler.setStyle('background-color', toggler.origColor);
}
});
}
CSS used in this example
.accToggler{
margin: 3px auto;
padding: 3px;
width: 400px;
background: #acc95f;
color: #f4f4f4;
border: 1px solid #fff;
cursor: pointer;
}
.accContent{
margin: 0px auto;
width: 400px;
}
©2006 solutoire.com