4 ms·
Is it possible to display a "There are no records" message if a container is empty (i.e. tbody) using CSS only?
by lucaspiller 10y ago
Is it possible to display a "There are no records" message if a container is empty (i.e. tbody) using CSS only?
- err4nt 10y agoThere is an :empty state you can use. I'm not looking at the demo right now but I've added messages like this: .container:empty:before { content: 'There are no Messages' }
- dahauns 10y agoJust be aware that the element really has to be empty - any whitespace (including empty child tags etc.) makes the selector ignore it.
- err4nt 10y agoYeah, whitespace makes a textNode so an element containing any nodes can't be :empty. Also gotta watch out for those whitespace-only extra nodes when counting the children of an element with JavaScript, it often returns more children than you think at first ;)