开发者

Styling divs that have dynamic names

My code creates CSS divs with dyna开发者_JAVA百科mic names

i.e.
  cke_record_body_19
  cke_record_body_54

Is it possible to style all divs that contain the string cke_record_body_ in their name using CSS?


The best cross browser solution is to style them by adding a class to each div.


Can you just have your code give these divs a class="cke_record_body" attribute? Then you can just apply a style to them however you want and ignore the ids.

If you really have to this should work:

div[id*="cke_record_body_"] {

}

Keep in mind I believe this is CSS3 so I have no idea what current support is, but really this is the only way to do it in straight CSS without other libraries. If you are using jQuery or something see Nealv's answer.


sure:

$("[id^=cke_record_body]*").something()

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜