Selector CSS " y " - ¿Puedo seleccionar elementos que tienen varias clases?
Estoy tratando de seleccionar todos los elementos que tienen ambas etiquetas .checked
y .featured
. Así que básicamente, lo que estoy buscando es un selector "y"; no se si hay uno o no.
¿hay alguna solución para casos como este?
54
Author: Gabriele Petrioli, 2013-01-30
3 answers
Se usan ambos ( sin espacio entre ellos )
.checked.featured{
// ...
}
Referencia: http://www.w3.org/TR/selectors/#class-html
Ejemplo
div{margin:1em;padding:1em;}
.checked{color:green;}
.featured{border:1px solid #ddd;}
.checked.featured{
font-weight:bold;
}
<div class="checked">element with checked class</div>
<div class="featured">element with featured class</div>
<div class="featured checked">element with both checked and featured classes</div>
90
Author: Gabriele Petrioli,
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
2017-06-23 10:33:07
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
2017-06-23 10:33:07
Puedes simplemente "unir" dos clases así: .checked.featured
15
Author: Moseleyi,
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-01-30 08:07:52
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-01-30 08:07:52
Para expresar Y simplemente concatenar sus clases .checked.featured
que no se pueden confundir con el popular .checked .featured
que es el selector descendiente.
7
Author: Christoph,
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-01-30 08:10:59
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-01-30 08:10:59