属性选择器选择 [英] Attribute Selector select

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

问题描述

嗨!!!

我对css有疑问。

我有一个代码:





Myid是固定的。我想用css一样:



div [id =Myid *] {}



如何我可以选择所有元素都有结构MyId *。不使用Jquery。

解决方案

我们可以通过使用CSS3实现它:nth-​​child()选择器< br $> b $ b

 使用公式(an + b)。说明:a代表循环大小,n  一个计数器(从 0 开始), b  一个偏移值。

这里,我们指定一个css for 索引的所有MyId元素 3的多个

MyId:nth-​​child(3n + 0)
{
//在此输入你的css
}


hi


使用class而不是ID。



我们可以多次使用class ...


 <   div     class   = < span class =code-keyword> MyId >  
< div class = MyId > < / div >
< div class = MyId > < / div >
< / div >


Hi !!!
I have a question about css.
I have a code:



Myid is fixed. I want to use css same:

div[id="Myid*]{}

How can i select all element have structure MyId*. Not use Jquery.

解决方案

we can achieve it by using CSS3 :nth-child() Selector

Using a formula (an + b). Description: a represents a cycle size, n is a counter (starts at 0), and b is an offset value.

Here, we specify a css for all MyId elements whose index is a multiple of 3:

MyId:nth-child(3n+0)
{
//type Your css here
} 


hi
use class instead of ID.

we can use class more than one time...

<div class="MyId">
<div class="MyId"></div>
<div class="MyId"></div>
</div>


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

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