I have a div#content with many div.item inside it.
When using :last-child to make the last div.item with no border-bottom, it’s OK.
But, as the content is dynamically appended using php and mysql results I’m using a conditional pagination table that will be appended after the last div.item which means at the bottom of the div#content. Here will be the problem as the CSS :last-child will not recognize the last div.item as the last-child.
my CSS looks like:
div#content div.item:last-child {
border-bottom: none;
}
as you can see I’m defining that the last child id such a div.item
Any suggestions please. thanks in advance.
!!!!! Please note that the problem is not in the fact that the content is dynamic but in the fact that the CSS :last-child doesn’t recognize the div.item as the last child but the last element in the div#content despite telling the CSS that it’s:
div#content div.item:last-child
One possibility I can think of is that you’re appending elements that aren’t
<div>s and/or don’t have theitemclass. Check the output of your PHP/MySQL script and see if there are any non-div.itemelements beside (in DOM terms) thediv.itemelements.Such elements will not match the selector:
That selector finds only
<div>s withitemclass, that are the last child ofdiv#content.Here’s an example.
Before appending
After appending
What’s being selected, what’s not, and why?
Selected
This
<div>element has theitemclass, and it’s the last child ofdiv#content.It exactly matches the above selector.
Not selected
This
<div>element has theitemclass, but is not the last child ofdiv#content.It doesn’t exactly match the above selector; however, it can possibly match either one of these selectors:
Not selected
Although this
<div>element is the last child, it does not have theitemclass.It doesn’t exactly match the above selector; however, it can possibly match this: