Ver Mensaje Individual
  #9 (permalink)  
Antiguo 10/04/2011, 14:04
Avatar de IsaBelM
IsaBelM
Colaborador
 
Fecha de Ingreso: junio-2008
Mensajes: 5.032
Antigüedad: 15 años, 10 meses
Puntos: 1012
Respuesta: Mostrar centrado un DIV aunque se salga de pantalla

tienes razón cuando dices que no lo probé, solamente lo analicé mentalmente y por lo visto no muy bien. ahora entiendo a que te refieres, aunque creo que no es lo que el usuario pretende. yo entiendo que cuando la resolución es menor se crea scroll horizontal y quiere que al abrir la página, ésta se scrollé hasta el centro. dejando así el desbordamiento lateral accesible y no solapado

siguiendo con tu código, he hecho esto casi que al vuelo. se acerca a lo que haces, mantener el centro con left:50%, sólo que no hay solapamiento del bloque central, cuando llega al tope del ancho. qué te parece??
Cita:
<!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">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Page</title>
<style type="text/css">
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
position: relative;
}

.marca_central {
position: absolute;
left: 50%;
top: 0;
width: 2px;
margin-left: -1px;
height: 100%;
background-color: #000;
z-index: 10;
}


#contenedor {
margin: 0 auto;
width: 1000px;
height: 80%;
}

.contenido {
width: 100%;
height: 100%;
background-color: yellow;
}
</style>
</head>

<body>
<div id="contenedor">
<div class="contenido">Texto</div>
</div>

<div class="marca_central"></div>
</body>

</html>