I have a div which may / may not contain content. When the div does not contain content, I would like it to disappear.
Firefox seems to have a grasp on this, however IE still displays the div. I have tried adding any empty comment, and whilst the div is not displaying, the area where it used to be still exists and other content is wrapping around it, which is not what I want, I would like it to completely disappear.
This removes the empty div, but there can be a lot of better ways, specially if you can use php. The problem of this solution is that it needs a little playing, you should make sure that the div contents when empty are absolutely nothing, and also it needs javascript to be enabled.
You are welcome. No, I don't think that there can be a pure CSS solution, as CSS is not content related. You need something to be dynamic, CSS is static.
Would you please tell me what did you do for Firefox? Well, as I know, this should be a non-standard solution. I would appreciate if you send your FF solution.
The reason it's not showing up in Firefox then is because there is no height declared, and is thus appearing to be "invisible". What is actually happening is that the div, because it's empty, has a height of 0px, so cannot be seen, but it is still there.
However it doesn't hide my div with the structure I have:
I have a wrapper with a display:table
I have an inner wrapper with dispay:table-row
I have wrapper within that with display:table-cell
and within this I have 3 x columns.
If I set the CSS to column 1 to display:none; the column disappear and column 2 stretches to fill it's place. Likewise if I apply the css to column3. However this isn't working when I want to dynamically hide it using the javascript above. Is the javascript above not compatible with the structure I have. Is there a way to achieve this using .net or php?
Bookmarks