2012-02-12 118 views

回答

1

是:

div.your-style > textarea{ 
    height: 60px; 
} 
+5

由于OP显然是新的CSS,但应注意的是,这仅适用于文字区域是在div的*直接*孩子,如果它们是包装在标签或其他div中,则不起作用:http://reference.sitepoint.com/css/childselector。 OP可能需要一个简单的[后代选择器](http://reference.sitepoint.com/css/descendantselector)。 – 2012-02-12 23:38:36

0
<div id="xxx" 

<div class="yyy" 

css: 

#xxx{ anything with id xxx 
} 

.yyy{ anything with class yyy 
} 

div{ all div(s) 
} 

div.yyy{ the div with class yyy 
} 

div #xxx{ the div's sub element with id xxx 
} 

div .yyy{ the div's sub element with class yyy 
} 

.yyy div{ any div inside a element with class yyy 
} 
0
.foo textarea { 
    color: red; 
} 

与一类foo更改所有文本区域的内部元素的字体颜色。

1

例如,你可以这样做:

div.classname textarea 
{ 
    // css 
} 
0

对于所有的文字区域

textarea{color:black} 

对于某些textarea的id为 'mydiv'

一个div内
#mydiv > textarea{color:red} 

使用类“mydiv”一个div

.mydiv > textarea{color:gray} 
0

你可以做到这一点没有或没有新的CSS选择器,这是内部的某些文本区域 - > 要么.yourclass img{}.yourclass->img{}会做同样的事情。

2

HTML:

<div id="dv1"> 
    <div class="dv2"></div> 
</div> 

CSS:

#dv1{ ... } 
.dv2{ ... } 
#dv1 .dv2{ ... } 
+0

这看起来是一个很好的例子 – Ravia 2012-02-13 15:44:51