Mira un ejemplo que hice para ti
Código HTML:
Ver original<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Simple Javascript Accordions - by www.dezinerfolio.com
</title> * {
margin:0;
padding:0;
list-style:none;
}
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
margin:10px;
}
#basic-accordian{
border:5px solid #EEE;
padding:5px;
width:350px;
position:absolute;
left:621px;
top:140px;
margin-left:-175px;
z-index:2;
margin-top:-100px;
}
.accordion_headings{
padding:5px;
background:#99CC00;
color:#FFFFFF;
border:1px solid #FFF;
cursor:pointer;
font-weight:bold;
}
.accordion_headings:hover{
background:#00CCFF;
}
.accordion_child{
padding:15px;
background:#EEE;
}
.header_highlight{
background:#00CCFF;
}
<script type="text/javascript" src="accordian.pack.js"></script> <body onload="new Accordian('basic-accordian',5,'header_highlight');">
<div id="basic-accordian" ><!--Parent of the Accordion-->
<div align="center">Simple Accordions
</div>
<?php
$Pais = array(
"Mexico" =>"Pais muy bonito, con mujeres muy lindas",
"Colombia" => "Pais muy bonito con mujeres lindas y comparonas",
"Peru" => "Pais de muchas produciones y bonito");
$a = 0;
foreach($Pais as $row => $field):?>
<!--Start of each accordion item-->
<div id="test<?=$a?>-header" class="accordion_headings" >
<?=$row?></div><!--Heading of the accordion ( clicked to show n hide ) -->
<!--Prefix of heading (the DIV above this) and content (the DIV below this) to be same... eg. foo-header & foo-content-->
<div id="test<?=$a?>-content">
<!--DIV which show/hide on click of header-->
<!--This DIV is for inline styling like padding...-->
<div class="accordion_child"><?=$field?><br />
<? $a++; endforeach; ?>
<a href="05.html" style="float:left">Previous Demo
</a> <a href="02.html" style="float:right;">Next Demo
</a>
</div><!--End of accordion parent-->