开发者

DIV filling 100% of an unknown parent element

There is a div element I have complete control over, including its contents, associated JS event handlers and style options. This div will 开发者_如何学JAVAbe inserted into some web page template I don't know anything about, i.e. it may be inserted into a table cell, or into complex div-based markup, etc. I need to be able to build this div in such a way that would allow it to occupy a predictable area inside the parent elements it's being inserted into.

  • How many positioning schemes for do I need to support for different use cases?
  • Are there any restrictions on the web page templates I'd better set so that my div construction subroutine doesn't turn into an unmaintainable mess?
  • What would be more natural, expanding the div to take 100% of available area, or resizing to the given width and height?


Personally, I would simply set it to fill the parent container (which can be a task in itself in CSS2).

This way, whomever is controlling the template can decide the eventual size of your div by influencing the parent container. If they want it to fill the container, they just leave is as-is - if they want to restrict it or position it in some way, they can place it in a block element and dictate the size/shape/positioning of the block.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜