cierto el contenedor debe tener un width:auto;
|
|
#1 (permalink) |
![]() Fecha de Ingreso: septiembre-2007
Mensajes: 5
|
cierto el contenedor debe tener un width:auto; |
|
|
|
|
|
#2 (permalink) |
|
Colaborador
![]() ![]() ![]() ![]() ![]() ![]() ![]() Fecha de Ingreso: octubre-2006
Ubicación: K-pax
Mensajes: 4.998
|
Respuesta: Centrar dos divs
Podrías probar poniendo a los dos divs display:inline; y a su contenedor text-align: center; aunque que funcione o no dependerá de cómo tienes el resto de elementos.
Mikel. |
|
|
|
|
|
#3 (permalink) |
![]() Fecha de Ingreso: octubre-2004
Mensajes: 143
|
Respuesta: Centrar dos divs
Mira si esto te sirve. He coloreado los fondos de los divisores para ver mejor el efecto.
Código HTML:
<body> <div id="caja_envolvente" style="position: absolute; width:600px; height:300px; margin-left: -300px; margin-top: -150px; z-index:1; left: 50%; top: 50%; background-color:#C0C0C0"> <div style="position: absolute; width: 400px; margin-left: -200px; left: 50%"> <div id="primer_divisor" style="width: 200px; height: 200px; float:left; background-color:#FFFF00">Contenido 1</div> <div id="segundo_divisor" style="width: 200px; height: 200px; float:left; background-color:#FF0000">Contenido 2</div> </div> </div> </body> Naturalmente los tamaños los debes adaptar a tu uso. Saludos |
|
|
|
|
|
#5 (permalink) |
![]() Fecha de Ingreso: septiembre-2007
Mensajes: 5
|
Respuesta: Centrar dos divs
Cita:
Gracias brother..lo voy a probar
Iniciado por ssclamp
Mira si esto te sirve. He coloreado los fondos de los divisores para ver mejor el efecto.
Código HTML:
<body> <div id="caja_envolvente" style="position: absolute; width:600px; height:300px; margin-left: -300px; margin-top: -150px; z-index:1; left: 50%; top: 50%; background-color:#C0C0C0"> <div style="position: absolute; width: 400px; margin-left: -200px; left: 50%"> <div id="primer_divisor" style="width: 200px; height: 200px; float:left; background-color:#FFFF00">Contenido 1</div> <div id="segundo_divisor" style="width: 200px; height: 200px; float:left; background-color:#FF0000">Contenido 2</div> </div> </div> </body> Naturalmente los tamaños los debes adaptar a tu uso. Saludos |
|
|
|
|
|
#7 (permalink) |
|
Colaborador
![]() ![]() ![]() ![]() ![]() ![]() ![]() Fecha de Ingreso: octubre-2006
Ubicación: K-pax
Mensajes: 4.998
|
Respuesta: Centrar dos divs
Otra manera:
Cita:
Mikel.<!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" lang="es-es"> <head> <title>centrado</title> <style type="text/css"> #contenedor { width: 600px; height: 400px; background-color: rgb(51, 153, 153); margin: 50px auto; } #centrado { width: 440px; margin: 0px auto; } #caja1, #caja2 { width: 200px; height: 200px; background-color: rgb(51, 102, 102); margin-top: 20px; } #caja1 { float: left;} #caja2 { float: right;} </style> </head> <body> <div id="contenedor"> <div id="centrado"> <div id="caja1"></div> <div id="caja2"></div> </div> </div> </body> </html> |
|
|
|