css all divs vs direct child divs
Tengo esta estructura:
<div class="Root">
<div>ddddddd</div>
<div>
<div>pppppppppp</div>
<div>pppppppppp</div>
</div>
<div>ddddddd</div>
<div>
Quiero poner fronteras en el div
s que contienen ddddddd
, y quiero establecer el color del texto en todos div
s a verde.
Hay dos reglas:
- No puedo agregar atributos
class
. - Tengo que escribir selectores que comiencen con
.Root
.
¿Alguna idea?
27
3 answers
En realidad estaba buscando esto:
Selecciona los divs que son hijos directos de Root:
.Root > div {
border: 1px solid red;
}
Selecciona todos los divs en Root:
.Root div {
color:green;
}
62
Author: Naor,
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
2010-12-25 03:03:47
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
2010-12-25 03:03:47
¿Algo así?
.Root > :first-child, .Root > :last-child { border: 1px solid red }
.Root { color: green; }
Demo: http://jsfiddle.net/karim79/N5qFu/1 /
Les aconsejo que pasen por esto: http://www.w3.org/TR/css3-selectors /
8
Author: karim79,
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
2010-12-25 02:18: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
2010-12-25 02:18:59
.root { border: 1px solid green; }
¿Por qué no estás declarando class /id para otros divs?
-1
Author: 422,
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
2010-12-25 02:12:57
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
2010-12-25 02:12:57