Solved

How to make <div> auto resize with the browser window?

Posted on 2004-03-21
5
611 Views
Last Modified: 2007-12-19
In Windows application, we can use Anchor property to "link" Windows control to the edge of the windows form. When user resizes the Windows form, the control resizes together with the Widnows form.

Can I do the same thing in ASP.NET with <div>? Which means, if user resizes the Browser window, I want this <div> resizes with it. If <div> is not big enough to hold all the web content inside it, I want scroll bars automatically added for this <div>. Are there any way to do this?

Thanks a lot.
0
Comment
Question by:BruceCheng
5 Comments
 
LVL 12

Accepted Solution

by:
esteban_felipe earned 84 total points
ID: 10646939
Hi BruceCheng,

Not really... <div> tags are supposed to use all available width of the container tag (all window width if it's inside <body> or all the cell width if it is inside <td>) unless you specify a width in the style property. The height will be set by the content. It will take all the height necessary to render it's content.

If you want scrollbars, then you should move to an IFrame tag.

This is not really related to ASP.NET but rather with HTML code (ASP.Net is the framework that allow you to do object oriented server programming to emit html/javascript code that simulate events). HTML by itself is very limited for appereance.. this is why webmaster/graphics designers usually make good money :)

Esteban Felipe
www.estebanf.com
0
 

Assisted Solution

by:Dekkert
Dekkert earned 83 total points
ID: 10647283
Regarding the scrollbar issue:
Have a look at the overflow property of css. That should do the trick.

Regarding the "resize" issue:
There are a lot of javascripts out there that "measure" the size of the window it's in. Given that, it's possible to dynamically resize the div. Like Esteban said, this has nothing to do with programming, more with HTML/CSS/Javascript.

Good luck!
0
 
LVL 4

Assisted Solution

by:locitt
locitt earned 83 total points
ID: 10654074
try this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script language=javascript>

window.onload = setAutosize;

function setAutosize()
{
      document.all("theDIV").style.setExpression("width", "document.body.clientWidth");
      document.all("theDIV").style.setExpression("height", "document.body.clientHeight");
}

</script>
</HEAD>

<BODY leftmargin=0 topmargin=0>
<div id=theDIV style="position: absolute; left: 0px, top: 0px; background-color: black; overflow: auto">
</div>
</BODY>
</HTML>


locitt.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now