Uso: después de borrar elementos flotantes
Tengo una lista y las li tienen un float:left;
. El contenido después de <ul>
debe estar alineado correctamente. Por lo tanto, puedo construir lo siguiente:
Pensé, que puedo eliminar el <div class="clear">
mediante el uso de pseudo selectores como :después.
Pero el ejemplo no funciona:
¿Siempre tengo que crear un div separado para borrar elementos flotantes?
5 answers
Escribe así:
.wrapper:after {
content: '';
display: block;
clear: both;
}
Compruebe esto http://jsfiddle.net/EyNnk/1 /
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-01-28 00:34:03
No, no es suficiente hacer algo como esto:
<ul class="clearfix">
<li>one</li>
<li>two></li>
</ul>
Y el siguiente CSS:
ul li {float: left;}
.clearfix:after {
content: ".";
display: block;
clear: both;
visibility: hidden;
line-height: 0;
height: 0;
}
.clearfix {
display: inline-block;
}
html[xmlns] .clearfix {
display: block;
}
* html .clearfix {
height: 1%;
}
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-05-22 09:36:07
Esto también funcionará:
.clearfix:before,
.clearfix:after {
content: "";
display: table;
}
.clearfix:after {
clear: both;
}
/* IE 6 & 7 */
.clearfix {
zoom: 1;
}
Da la clase clearfix
al elemento padre, por ejemplo tu elemento ul
.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-01-20 07:27:52
El texto 'dasda' nunca no estará dentro de una etiqueta, ¿verdad? Semánticamente y para ser HTML válido como para ser, simplemente agregue la clase clear a eso:
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-05-22 09:35:16
Use
.wrapper:after {
content : '\n';
}
Muy similar a la solución proporcionada por Roko. Permite insertar / cambiar contenido usando :after y: before psuedo. Para más detalles, consulte http://www.quirksmode.org/css/content.html
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-05-02 13:08:47