Ver Mensaje Individual
  #1 (permalink)  
Antiguo 26/07/2016, 11:21
Avatar de LordJhony
LordJhony
 
Fecha de Ingreso: septiembre-2010
Mensajes: 472
Antigüedad: 13 años, 8 meses
Puntos: 24
Hacer que una tabla se ajuste al tamaño de sus elementos.

Hola...
Tengo el siguiente código html

Código HTML:
<html>
 <head>
  <title>Angelus Books. The Best Books That I Read</title>
  <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
  <link href="/Libreria/Vista/CSS/cabecera.css" rel="stylesheet" type="text/css"/>
  <link href="/Libreria/Vista/CSS/buscar.css" rel="stylesheet" type="text/css"/>
 </head>
<body>
<header>
 <!-- Elementos contenidos en el header -->
</header>
<section>
   <div>
     <center>
        <table id="tresultado">
          <tr class="tr">
             <td class="td"><img id="portada" src="imagen1.jpg>
             <br />Nombre imagen 1</td>
             <td class="td"><img id="portada" src="imagen2.jpg>
             <br />Nombre imagen 2</td>
             <td class="td"><img id="portada" src="imagen3.jpg>
             <br />Nombre imagen 3</td>
             <td class="td"><img id="portada" src="imagen4.jpg>
             <br />Nombre imagen 4</td>
     </tr>     
   </table>
  </center>
 </div>
</section>
</body></html> 
A ese código le aplico los siguientes estilos css

Código CSS:
Ver original
  1. #tresultado{
  2.     background-color: #5C5CA3;        
  3. }
  4. .tr{
  5.     background-color: #5C5CA3;
  6.     width: auto;
  7.     height: 150px;
  8. }
  9. .td{
  10.     background-color: #5C5CA3;
  11.     width: 100px;
  12.     height: auto;
  13.     position: relative;
  14.     top: 110px;    
  15. }
  16. #portada{
  17.     width: 100px;
  18.     height: 150px;  
  19. }

El problema es que las imágenes quedan por fuera de la tabla, y yo necesito que la tabla sea exactamente del tamaño de las figuras incluido sus respectivos nombres. He intentado cambiándole las propiedades width y height a todos los elementos incluida la misma tabla, y aun no logro conseguirlo.
De antemano, gracias por su ayuda.