/    Sign up×
Community /Pin to ProfileBookmark

How do I get a div size to adjust dynamically?

I have a div in my webpage that I want to resize to the size of the browser. Does anyone know of the right tag to do this?

I have theNode.style.top at 0 pixels and theNode.style.left at 0 pixels. Also right now I have theNode.style.height=770; and theNode.style.width=1255; I want these two sizes to be dynamic to the browser width. Can someone please explain to me how I would do this?

function doMessage ()
{
createGreyLayer();
t=setInterval(“fadeDown()”,50);
}

function createGreyLayer()
{
var theBody = document.getElementsByTagName(“body”)[0];
var theNode = document.createElement(‘div’);
theNode.style.position=’absolute’;
theNode.style.top=’0px’;
theNode.style.left=’0px’;
theNode.style.opacity=0.00;
theNode.style.MozOpacity=0.00;
theNode.style.KhtmlOpacity=0.00;
theNode.style.filter=”alpha(opacity=100)”;
theNode.style.height=770;
theNode.style.width=1255;
theNode.style.backgroundColor=”#c0c0c0″;
theNode.style.display=”block”;
theNode.style.zIndex=’1′;
theNode.id=’GreyLayer’;
theBody.appendChild(theNode);
}

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@FangNov 30.2010 — Percentage
Copy linkTweet thisAlerts:
@rnd_meNov 30.2010 — css:
[CODE]#myDiv {width:100%;}[/CODE]
×

Success!

Help @calaberator spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...