Making a div auto space...

N

Nony Buz

I have a simple question:

I have a given work space, 760x420, full screen for the 800x600
user. When a user running at 800x600 views my site, I want the
main workspace DIV to not have any space at the top. But if there
is enought room, I want there to be a 40px margin between the
760x420 and the top of the browser. How do I do that without
server side code?
 
N

Neredbojias

To further the education of mankind said:
I have a simple question:

I have a given work space, 760x420, full screen for the 800x600
user. When a user running at 800x600 views my site, I want the
main workspace DIV to not have any space at the top. But if there
is enought room, I want there to be a 40px margin between the
760x420 and the top of the browser. How do I do that without
server side code?

Javascript.

if (screen.width>800) document.getElementById
('workdiv').style.marginTop='40px';
 
N

Nony Buz

Javascript.

if (screen.width>800) document.getElementById
('workdiv').style.marginTop='40px';

I tried it and it does not seem to work in either Firefox or IE.
here is my code:

<html>
<head>
<title>New Website</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<style type="text/css">
<!--
body {
background-color: #000033;
color: #000000;
font-family: Arial, Helvetica, sans-serif;
font-size: 10pt;
margin: 0px auto;
text-align: center;
}

#main {
background-image: url(images/BlueGray.gif);
height: 420px;
width: 760px;
margin: 0px auto;
text-align: left;

}
-->
</style>
</head>
<script type=text/javascript>
if (screen.width>800)
document.getElementById('main').style.marginTop='40px';
</script>
<body>
<div id="main">
</div>
</body>
</html>
 
N

Neredbojias

I tried it and it does not seem to work in either Firefox or IE.
here is my code:
</style>
</head>
<script type=text/javascript>
if (screen.width>800)
document.getElementById('main').style.marginTop='40px';
</script>
<body>
<div id="main">
</div>
</body>
</html>

Include the js _within_ the <body> container after the "main" div.

Javascript should always be in either the <head> or <body> section.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top