Ver Mensaje Individual
  #9 (permalink)  
Antiguo 06/02/2013, 10:42
Avatar de emprear
emprear
Colaborador
 
Fecha de Ingreso: junio-2007
Ubicación: me mudé
Mensajes: 8.388
Antigüedad: 16 años, 11 meses
Puntos: 1567
Respuesta: capa con mostrar más

Como te dije hay nuchas variantes, me olvidé del detalle de ocultar las restantes, se puede hacer asi (uso otra técnica comparando los indices de los elementos)

Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <title>mostrar oculta capas</title>
  5. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  6. <style type="text/css">
  7. /*<![CDATA[*/
  8. p{
  9. font-weight: bold;
  10. cursor: pointer;
  11. }
  12. #contenedor{
  13. width: 300px;
  14. }
  15. .faqs{
  16. /* display: none; */
  17. text-overflow: ellipsis;
  18. overflow: hidden;
  19. white-space: nowrap;
  20. padding: 3px;
  21. background: #DFD2C8;
  22. margin:5px 1px 5px 1px;
  23. border-top: dotted 1px darkred;
  24. cursor: pointer;
  25. }
  26. .faqs span{
  27. display: block;
  28. cursor: pointer;
  29. font-size: 11px;
  30. margin-top: 10px;
  31. }
  32. #contenedor p{
  33. margin-bottom: 0;
  34. background: #DFD2C8;
  35. }
  36. /*]]>*/
  37. <script type="text/javascript">
  38. //<![CDATA[
  39. function contenido(cual){
  40. var i;
  41. var principal = document.getElementById ("contenedor");
  42. var capas = [];
  43. var divTags = principal.getElementsByTagName ("div");
  44. for (var i = 0; i < divTags.length; i++) {
  45. capas.push(i);
  46. }
  47.    for(i in capas){
  48.        if(capas[i] == cual){
  49.        divTags[i].style.overflow = 'auto';
  50.        divTags[i].style.whiteSpace = 'normal';
  51.          divTags[i].title = '';  
  52.        }else{
  53.       divTags[i].style.overflow = 'hidden';
  54.        divTags[i].style.whiteSpace = 'nowrap';
  55.        divTags[i].title = 'Ver más detalles';        
  56.        }
  57.    }
  58. }
  59. //]]>
  60. </head>
  61. <div id="contenedor">
  62.  
  63. <div class="faqs" onclick="contenido(0)" title="Ver más detalles">Texto uno Lorem ipsum dolor sit  amet, consectetur adipiscing elit.  Aenean euismod vestibulum elit  non condimentum. Pellentesque vitae adipiscing sem</div>
  64.  
  65. <div class="faqs" onclick="contenido(1)" title="Ver más detalles">Texto dos Lorem ipsum dolor sit  amet, consectetur adipiscing elit.  Aenean euismod vestibulum elit  non condimentum. Pellentesque vitae adipiscing sem</div>
  66.  
  67. <div class="faqs" onclick="contenido(2)" title="Ver más detalles">Texto tres Lorem ipsum dolor sit  amet, consectetur adipiscing elit.  Aenean euismod vestibulum elit  non condimentum. Pellentesque vitae adipiscing sem</div>
  68. </div>
  69. </body>
  70. </html>
A esta le podría faltar, si se quiere, alguna forma de ocultar la que queda abierta, pero a eso no le dediqué tiempo todavía

Aqui hay 2 más por si estás aburrido
http://foros.emprear.com/javascript/...ctexto_nt.html
http://foros.emprear.com/javascript/...as-ctexto.html

Por compatibilidad no hay problema, las que te dejé antes, corren en todos los navegadores (ie a partir del 8), incluso en OperaMini y el Nokia Browser tembién (ajustes de los tamaños mediante)

Saludos
__________________
La voz de las antenas va, sustituyendo a Dios.
Cuando finalice la mutación, nueva edad media habrá
S.R.