On a div开发者_如何学编程 I have css set:
div.class {border: 1px solid red;}
The div is positioned absolutely in the center of the page. The problem is that the border appears even if there is no content.
Any css methods to get the border to not appear if there is no content?
CSS3 has a selector defined for this case. It does not work in IE8 and lower though.
div.class:empty {
border: none;
}
Your best option would be to tweak this on the server side, and simply don't display that div if it would be empty.
If the div can have content related to a server response, you can tell whether it is an empty or a filled response and change to display:none or display:block accordingly
精彩评论