Insertar HTML desde CSS
¿Hay alguna forma de insertar un elemento HTML, dom o código desde CSS(3)?
5 answers
Contenido (para texto y no html):
Http://www.quirksmode.org/css/content.html
Pero para ser claros, es una mala práctica. Su soporte en todos los navegadores es inestable, y generalmente no es una buena idea. Pero en los casos en que realmente tienes que usarlo, ahí está.
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
2018-05-02 13:35:04
No. Lo único que puede hacer es agregar contenido (y no un elemento) usando :before
o :after
pseudo-elemento.
Más información: http://www.w3.org/TR/CSS2/generate.html#before-after-content
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
2011-02-02 20:56:09
No, no puedes. Lo único que puedes hacer es insertar contenido. Así:
p:after {
content: "yo";
}
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
2011-02-02 20:55:58
Una alternativa - que puede funcionar para usted dependiendo de lo que esté tratando de hacer - es tener el HTML en su lugar y luego usar el CSS para mostrarlo u ocultarlo dependiendo de la clase de un elemento padre.
O
Use jQuery append ()
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-10-10 12:56:09
Esto se puede hacer. Por ejemplo con Firefox
CSS
#hlinks {
-moz-binding: url(stackexchange.xml#hlinks);
}
Stackexchange.xml
<bindings xmlns="http://www.mozilla.org/xbl"
xmlns:html="http://www.w3.org/1999/xhtml">
<binding id="hlinks">
<content>
<children/>
<html:a href="/privileges">privileges</html:a>
<html:span class="lsep"> | </html:span>
<html:a href="/users/logout">log out</html:a>
</content>
</binding>
</bindings>
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
2013-12-21 11:34:53