Pregunta

Tengo este código:

<style type="text/css">
    body > div { height: 260px; overflow: hidden; }
    div div { float: left; height: 250px; width: 250px; margin: 1px; background: #ccc; }
</style>

<div>
    <div>first 1</div>
    <div>first 2</div>
    <div>first 3</div>
    <div>first 4</div>
    <div>first 5</div>
</div>

Quiero dar a este márgenes cajas de cambiar de manera uniforme.

¿Fue útil?

Solución

Como el ancho del contenedor es desconocida, y la anchura de la divs se fija en píxeles (descartando un sistema basado en porcentaje) -. No se puede hacer esto con CSS

Se podría centrar ellos utilizando la técnica descrita en el http://matthewjamestaylor.com/blog/beautiful-css-centered-menus-no-hacks-full-cross-browser-support o usted podría mirar hacia JavaScript (o puede establecer el ancho del elemento padre a un valor conocido).

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top