这些选择器之间的区别 [英] Difference between these selectors

查看:142
本文介绍了这些选择器之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这些选择器之间有什么区别吗?



div.demo div .demo



div#demo div #demo



是否选择相同的元素?

  div.demo {some code} 
div .demo {some code}


解决方案

是的,有。



div.demo code> div 与类别 demo

 < div class =demo> 

div .demo code> demo 在任何 div 中:

 < div> 
< span class =demo>
< / div>

与id选择器相同 / p>

Is there any difference between these selectors?

div.demo and div .demo

div#demo and div #demo

Does it select the same element?

div.demo{some code}
div .demo{some code}

解决方案

Yes, there is.

div.demo will match a div with class demo

<div class="demo">

div .demo will anything with class demo inside any div:

<div>
  <span class="demo">
</div>

Same with the id selector #.

这篇关于这些选择器之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆