Click here to Skip to main content
16,022,901 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
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.
Posted

hi
use class instead of ID.

we can use class more than one time...

HTML
<div class="MyId">
<div class="MyId"></div>
<div class="MyId"></div>
</div>
 
Share this answer
 
Comments
baotdinh 11-Jun-13 6:31am    
you don't understand my question ^^.
<div id="MyId_123"></div>
<div id="MyId_234"></div>
I want to apply css for elements have structure id like MyId*. Ex: MyId_123,MyId_234.
we can achieve it by using CSS3 :nth-child() Selector

VB
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
} 
 
Share this answer
 
v2
Comments
baotdinh 11-Jun-13 6:07am    
I post lack code:
<div id="MyId_123"></div>
<div id="MyId_234"></div>

How can i apply ???

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900