RE: [PHP-ES] OFFTOPIC. Barra flotante CCS
| From: | Marcos Gonzalez Castro | Date: | Tue, 25 Nov 2003 17:53:21 +0000 |
| Subject: | RE: [PHP-ES] OFFTOPIC. Barra flotante CCS | ||
| Groups: | php.general.es | ||
| Request: | Send a blank email to general-es+get-43003@lists.php.net to get a copy of this message | ||
A ver si te he entendido:
¿Quieres mostrar una tabla que independientemente de lo larga o ancha que
sea muestre siempre la cabecera, permitiendo hacer scroll por el contenido?
Si es esto, una solución que funciona en IE y Mozilla (supongo que en los
demás navegadores modernos también) es la siguiente:
Creas dos tablas, una para las cabeceras y otra para el contenido. Iguala
los anchos de los <td> y <th> y mételas en sendos <div> para poder aplicar
un "height" menor que el alto de la página y un "overflow: auto".
Aquí te adjunto algo de código.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Tabla con cabeceras fijas</title>
<style type="text/css">
.head, .contents {
width: 400px;
border: 1px solid black;
}
table {
width: 100%;
}
td {
background-color: darkgreen;
color: white;
border-right: 1px solid white;
}
th {
background-color: darkred;
color: white;
border-right: 1px solid white;
}
.contents {
position: relative;
height: 100px;
overflow: auto;
}
</style>
</head>
<body>
<div>
<div class="head">
<table cellspacing="0">
<tr>
<th style="width:100px">A</th>
<th style="width:150px">B</th>
<th>C</th>
</tr>
</table>
</div>
<div class="contents">
<table cellspacing="0">
<tr>
<td style="width:100px">A1</td>
<td style="width:150px">B1</td>
<td>C1</td>
</tr>
<tr>
<td style="width:100px">A2</td>
<td style="width:150px">B2</td>
<td>C2</td>
</tr>
<tr>
<td style="width:100px">A3</td>
<td style="width:150px">B3</td>
<td>C3</td>
</tr>
<tr>
<td style="width:100px">A4</td>
<td style="width:150px">B4</td>
<td>C4</td>
</tr>
<tr>
<td style="width:100px">A5</td>
<td style="width:150px">B5</td>
<td>C5</td>
</tr>
<tr>
<td style="width:100px">A6</td>
<td style="width:150px">B6</td>
<td>C6</td>
</tr>
<tr>
<td style="width:100px">A7</td>
<td style="width:150px">B7</td>
<td>C7</td>
</tr>
<tr>
<td style="width:100px">A8</td>
<td style="width:150px">B8</td>
<td>C8</td>
</tr>
<tr>
<td style="width:100px">A9</td>
<td style="width:150px">B9</td>
<td>C9</td>
</tr>
</table>
</div>
</div>
</body>
</html>
> -----Mensaje original-----
> De: Rob [mailto:rolvrs@netscape.net]
> Enviado el: martes, 25 de noviembre de 2003 18:17
> Para: lista@phpes.com
> Asunto: [PHP-ES] OFFTOPIC. Barra flotante CCS
>
>
> Saludos.
>
> He hecho algunos reportes de una base de datos mysql con php y me han
> pedido que se pueda inmovilizar los encabezados de columnas
> del reporte.
> Algo como la gracia que hace excel al fijar columnas o renglones. La
> idea es que despues de avanzar varios renglones en le reporte
> se pueda
> distinguir fácilmente a que corresponde cada dato.
> He logrado hacer la barra de encabezados fija usando CCS pero
> tengo el
> problema de que, si el reporte es tan amplio que genera scroll
> horizontal, la barra de encabezados no se corresponde con las
> columnas.
> El ancho máximo que le he podido dar a la barra es el de la
> resolución
> del monitor.
> Hay alguna forma de darle mayor y que se pueda corresponder con las
> columnas a pesar del scroll horizontal?
> Por otra parte he visto que la barra no funciona bien en IE
> pero no he
> encontrado la forma de arreglarlo. Alguna ayuda por favor? He
> encontrado
> varios sitios que manejan lo de las barras flotantes pero ninguna que
> trabaje bien con IE.
>
>
>
> ---------------------------------------------------------------------
> Archivo On-line: http://www.phpes.com/
> via news: news://news.phpes.com/
> Manual PHP en español: http://www.php.net/manual/es/
> Para dar de baja la suscripción, mande un mensaje a:
> lista-unsubscribe@phpes.com
>
------------------------------------------------------------
Este mensaje, y los documentos en su caso anexos, se dirigen exclusivamente
a su destinatario y pueden contener información reservada y/o CONFIDENCIAL
cuyo uso no autorizado o divulgación está prohibido por la legislación
vigente. Si ha recibido este mensaje por error, le rogamos que nos lo
comunique inmediatamente por esta misma vía o por teléfono (34 981185400) y
proceda a su destrucción.
This message and its attachments are intended exclusively for the addressee
and may contain information that is privileged and/or CONFIDENTIAL. Its non
authorized use or disclosure is prohibited by law. If you are not the
intended recipient, please notify us immediately by the same channel as its
receipt or by telephone (34 981185400) and kindly destroy it.
------------------------------------------------------------