-1

Can I set the height of a div inside a table to 100%? Failing that, can I use a span instead?

I've seen this answer but it doesn't mention anything about 100%.

enter image description here

[I need to use divs because they have dynamic content loading into them]

EDIT

In the images below you'll see that display is table-cell, I've set it to block and inline-block with the same result

enter image description here enter image description here

5
  • 3
    you can load dynamic content into any element - just give it an identifier or smth Commented Oct 4, 2012 at 16:59
  • using dojos dojox.layout.ContentPane :( Commented Oct 4, 2012 at 17:00
  • then do div { display: table-cell; height: 100% } Commented Oct 4, 2012 at 17:03
  • I've tried table-cell to no avail Commented Oct 4, 2012 at 17:20
  • 1
    Try setting position: relative; on the container (<td>?), then setting height: 100%; on the div. Often when I'm having trouble with sizing, setting the position property clears things up. This property does have certain important side effects (such as changing the z-order), so it may cause problems for a complex layout (nothing that can't be overcome, though).
    – JDB
    Commented Oct 4, 2012 at 17:25

2 Answers 2

1

Yes you can as long as the element is block or inline-block as it states in the answer you posted. Div's are block level by default and spans are inline, so need css display:inline-block or display:block.

2
  • Is that really the only way? I have been messing around with block and inline-block for the last hour and they mess up my layout :( Commented Oct 4, 2012 at 17:15
  • I think you need to show more of your code so we can see what is happening and what you want to happen. Commented Oct 4, 2012 at 18:05
1

Like this? If you uncomment the // from before the height, it fills the td it is inside, is that what you are asking?

2
  • I think my code is more complex then I'm letting on that's why I'm getting these problems Commented Oct 4, 2012 at 17:17
  • Need to give us more information to help you then, do you have a link we can use?
    – Andy
    Commented Oct 5, 2012 at 8:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.