Hello
I'd like to select all divs beginning with "box"
This code doesn't work... Any idea ?
XHTML :
<div id="panier">
<div id="box1"> box1</div>
<div id="box2"> box2</div>
</div>
CSS :
#panier [id~="box"]
#panier [id~="box"] {
border: 1px solid black;
height: 50px;
width: 50px;
float: left;
}
Thanks!
EmilieWhy not give all of the divs the class name box? Thus:
<div id="panier">
<div class="box" id="box1"> box1</div>
<div class="box" id="box2"> box2</div>
</div>
Because I'm really not aware of a reliable, cross-browser way to match based on part of the ID.#panier div[id^="box"] { Only in FF First, why these are <div>s? looks like an <ul> to me...
Second, you do not need either id or class to style them:
#panier div
{ /* your declarations here */
}
will do the job without polluting the HTML code.In fact, i need to get the x/y of each div on my page to do drag&drop with javascript,
that's why i can't use classesIn fact, i need to get the x/y of each div on my page to do drag&drop with javascript,
that's why i can't use classes
I don't understand why you can't use classes. How would they impact it at all? Or, as was pointed out, target all divs in #panier
I'd like to select all divs beginning with "box"
This code doesn't work... Any idea ?
XHTML :
<div id="panier">
<div id="box1"> box1</div>
<div id="box2"> box2</div>
</div>
CSS :
#panier [id~="box"]
#panier [id~="box"] {
border: 1px solid black;
height: 50px;
width: 50px;
float: left;
}
Thanks!
EmilieWhy not give all of the divs the class name box? Thus:
<div id="panier">
<div class="box" id="box1"> box1</div>
<div class="box" id="box2"> box2</div>
</div>
Because I'm really not aware of a reliable, cross-browser way to match based on part of the ID.#panier div[id^="box"] { Only in FF First, why these are <div>s? looks like an <ul> to me...
Second, you do not need either id or class to style them:
#panier div
{ /* your declarations here */
}
will do the job without polluting the HTML code.In fact, i need to get the x/y of each div on my page to do drag&drop with javascript,
that's why i can't use classesIn fact, i need to get the x/y of each div on my page to do drag&drop with javascript,
that's why i can't use classes
I don't understand why you can't use classes. How would they impact it at all? Or, as was pointed out, target all divs in #panier