Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 986
  • Last Modified:

How can i set div height dynamically

I having a  placeholder it contains an usercontrol. So our placeholder contents  and  size varies every time.  Our need is on a menu selection we wants to place a div over that placeholder. But the issue is we want that div in placeholder height and width. Is any solution for this issue?


Logics Lab
1 Solution
try this,

<div id="dynamicDiv" runat="server" style="border:solid 1px #dcdcdc"></div>

dynamicDiv.Style.Add("height", "height of placeholder")
Well if your normale css is fine then you just do the following:

#1, if the div is in the placeholder: give it height and width 100%.
#2, if the placeholder is in the div: do nothing.

#1, Depending how you want it the div can take the height and with of the parent container which would be an placeholder here.

#2, If the placeholder is inside the div then it will automatically extend the size of the div around it since that div has a height which by default extend.

With kind regrads,

Kevin Hendricks
Specify NO height, only a width.   The DIV will expand to fill the content going into it, so your problem is solved because the content controls the height of the DIV.  If there is a containing DIV, leave the height of that unspecified too.

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now