Movement when browser resized

Hello All-

I tried different things to correct this problem but couldn’t get the email box and home button to stay put when the page was resized. If it helps the body of the page is done in flash as you can see below. Any suggestions would be greatly appreciated. Thank you in advance!

<html>
<title>my title</title>

<head>

<style type=“text/css”>
<!–
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
–>
</style>

<style type=“text/css”>
#home{
position: relative; left: 500px; top: 1200px; color: #333366;
</style>

<style type=“text/css”>
#phpform {
position: absolute; left: 350px; top: 575px;
}
</style>

</head>

<body>

<div id=“phpform”>
<form action=“step2.php” method=“post”>
Name:<br/><input type=“text” name = “username” /> <br/>
Email:<br/><input type=“text” name = “email” /> <br/>
Message:<br> <textarea style= “width: 200 px; height: 100 px;” row = “20” clos = “100” name=“message”> </textarea> <br/>
<input type=“submit” value=“Send” />
</form>
</div>

<div align = center>
<img src =“new_banner1.jpg” align = center>
</div>

<div align= center>
<object type=“application/x-shockwave-flash” data=“contact.swf” width=“800” height=“1024”>

    • <param name=“movie” value=“contact.swf” />
    • <param name=“wmode” value=“transparent” />
      </object>

<div id=“home”>
<a href = “index.html” style=“color: #000000”>Home</a>
</div>

</body>

</html>


<html>
<title>my title</title>

<head>

<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
#flash {
position: relative;
}
#home{
position: absolute: 500px; top: 1200px; color: #333366;

#phpform {
position: absolute; left: 350px; top: 575px;
}
-->
</style>

</head>

<body>

<div style="text-align: center;"> <!-- text-align also centers images ...</div>
<img src="new_banner1.jpg" /> <!-- no align needed here anymore, since the containing div centers its contents -->
</div>

<div id="flash" align="center"> <!-- I think text-align does not center objects, you need to try that ... -->
  <div id="phpform">
  <form action="step2.php" method="post">
  Name:<br/><input type="text" name = "username"/> <br/>
  Email:<br/><input type="text" name = "email"/><br/>
  Message:<br/><textarea style="width: 200 px; height: 100 px;" row="20" cols = "100" name="message"></textarea><br/>
  <input type="submit" value="Send" />
  </form>
  </div>
  <div id="home">
    <a href="index.html" style="color: #000000">Home</a>
  </div>

<object type="application/x-shockwave-flash" data="contact.swf" width="800" height="1024">
   <param name="movie" value="contact.swf" />
   <param name="wmode" value="transparent" />
</object>

</body>
</html>

You need to wrap the #phpform and #home in the #flash (newly created by me) so they are positioned relative to the offset of this div, and not relative to the offset of the <body>

Note that you might want to tweak the “left” and “top” css attributes now, because they are probably not correct anymore. Since I cannot see your web page I cannot tell you the new values :slight_smile:

BTW. Please don’t give div elements ids like “phpform”. Try as hard as you can to hide what kind of scripting language you are using (If hackers know that they can try attacks specific for that scripting language. Yes yes, I know it’s not bullet proof, but better than not doing it :slight_smile: )

Some other notes to make your page completely XHTML complient (which it looks like you want to do):

  • Use a Doctype
  • Close every tag, like <br/> (not <br>)
  • No spaces between attribute name, =, and value (NOT: <a href = “index.php”>…</a>, BUT: <a href=“index.php”>…</a>)
  • Quote all attributes (NOT: <a href=index.php>…</a>, BUT <a href=“index.php”>…</a>)
  • lastly (you did this correctly but I’m this for completeness sake) write all tags and attributes in lowercase (NOT <A HREF=“index.php”>…</a>, BUT <a href=“index.php”>…</a>)

Is there any reason you are using relative positioning to shift it over that much? Relative positioining moves the element visually but the element doesn’t move physically.

You should be able to do away with that absolute/relative positioning. If you could show us a visual of how you want the buttons layed out then that would help :slight_smile:

hey guys,

thank you again for your replies. Scallioxtx, I tried to incorporate the changes you recommended but what ended up happening is the form ended up between the banner and the body of the page. I was also not able to move the form to the location I needed. I tried to remodify it and got the right order, but now the form and home button site far down on the page. The code is below. Ryan Reese, I was trying to figure out this issue with the resizing and was flipping back and forth thinking it would make a difference with the positioning.

basically I need the banner aligned center with the body directly below it (which is the flash) I would need the home button directly aligned just below the body(flash) centered. The form would be sitting inside of the body(flash) about 60px to the left of center half way across. Hopefully that all makes sense.

<html>
<title>My Title</title>

<head>

<style type=“text/css”>
<!–
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}

#flash {
position: relative;
}

#home{
position: relative; left: 0px; top: 0px; color: #333366;

#form {
position: absolute; left: 350px; top: 200px;
}

–>
</style>

</head>

<body>

<div style=“text-align: center;”>
<img src=“new_banner1.jpg” />
</div>

<div style=“text-align: center;”>
<object type=“application/x-shockwave-flash” data=“contact.swf” width=“800” height=“1024”>
<param name=“movie” value=“contact.swf” />
<param name=“wmode” value=“transparent” />
</object>
</div>

<div id=“flash” align=“center”>
<div id=“form”>
<form action=“step2.php” method=“post”>
Name:<br/><input type=“text” name = “username”/> <br/>
Email:<br/><input type=“text” name = “email”/><br/>
Message:<br/><textarea style=“width: 200 px; height: 100 px;” row=“20” cols = “100” name=“message”></textarea><br/>
<input type=“submit” value=“Send” />
</form>
</div>

<div id=“home”>
<a href = “index.html” style=“color: #000000”>Home</a>
</div>

</body>

</html>

I can… almost see what you want.

But not totally.

I’ll add some stuff to Scallio’s post, because it may be affecting what you’re trying to do.

  1. Do you have a doctype? I don’t see one in the code you are posting, but if you want this page to have any chance of looking the same in IE and FF and Safari and Chrome and Opera and whoever else, you’ll want one.

  2. if you use code tags [code] then the smilies won’t screw up your HTML when you post it here. They’re eating your form, man!

  3. The <– comments in your CSS styles is for back when people used IE4 and Netscape. They no longer belong in stylesheets, remove them.
    3a. You can remove the margins from the body in an easier way:
    body {
    margin: 0;
    }

  4. Good forms have labels. <label for=“idoftheinput”>Label</label> Use them!

It seems you want a lot of stuff centered. If we could see some mockup (ascii art, ms paint, doesn’t matter, just needs to show positions and sizes of your boxes) then we could help figure out the best code for this.

BTW what browser do you look in when making this page? Do you look in more than one?

Hey thanks for your input Stomme poes. I made the changes you recommended below. I also attached a layout image to give you a better idea of what i was aiming for. Im trying to have the dark blue(banner) and the body(light blue and red) aligned center with no gap in between. The red would be the navigation bar (in different language so its on the opposite side). The home button would be centered at the bottom with the page. The yellow box would be sort of like a text box and the form would be the green box centered within it. Thanks again for all your help, its greatly appreciated.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html>
<title>My Title</title>

<head>

<style type="text/css">

body {
margin: 0;
}


#flash {
position: relative;
}

#home{
position: relative; left: 0px; top: 0px; color: #333366;


#form {
position: absolute; left: 350px; top: 200px;
}


</style>


</head>


<body>

<div style="text-align: center;"> 
<img src="new_banner1.jpg" /> 
</div>


<div style="text-align: center;"> 
<object type="application/x-shockwave-flash" data="contact.swf" width="800" height="1024">
   <param name="movie" value="contact.swf" />
   <param name="wmode" value="transparent" />
</object>
</div>


<div id="flash" align="center">
<div id="form">
  <form action="step2.php" method="post">
  <label for="name">Name:<br/></label>
  <input type="text" name = "username"/> <br/>
  <label for="email">Email:<br/></label>
  <input type="text" name = "email"/><br/>
  <label for="message">Message:<br/><textarea style="width: 200 px; height: 100 px;" row="20" cols = "100" name="message"></textarea><br/></label>
  <input type="submit" value="Send" />
  </form>
  </div>
  

<div id="home">
<a href = "index.html" style="color: #000000">Home</a>
</div>

</body>


</html>


also since I’ve added the doctype my text box width is long and changing the width values isn’t affecting it. I want to be able to use all browsers if possible (preferably IE and FF). Im looking at it through safari and FF.

Hi, for starters you’re having a typo in your css: #home doesn’t have the closing semi colon.

About the width of the textbox: add

textarea {width:350px;}

(adjust the width to your liking). And remove the inline styling.

To tired to look at the rest but i’m sure somebody will jump in to help you out :slight_smile:

Along with that, for the textarea you have spaces after the value and px

<textarea style="width: 200 px; height: 100 px;" row="20" cols = "100" name="message"></textarea>

Hmmm…

The red would be the navigation bar (in different language so its on the opposite side).

Since you’re from Dearborn, can I assume this might be a right-to-left page?

If so, know that some browsers get plenty wrong no matter how well you write the page. Opera, I’ve found, does rtl pages excellently. Safari3 and 4 are ok and Chrome is also ok.

If this will be a rtl page you’ll want to state that in the browser (a direction). I won’t go any further though because this is only a guess on my part… if I’m right, I can show you some other things to add to your page.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html>
<title>My Title</title>

You certainly want a good doctype if you want any chance of this page looking right in all the browsers, so good job.

But you’ll also want some meta tags… yes, the server ultimately sets your charset and MIME type but it’s still good to state these in your page… also language.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd"
<html [b]lang="nl"[/b]>
    [b]<meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta http-equiv="content-language" content="nl">[/b]
    <title>My Title</title>

The above has Dutch language as an example.

User agents may or may not grab your stated language but for those who do, this is a good way to steer them in the right direction.

If you’re getting a gap under your banner image…


<div style="text-align: center;"> 
<img src="new_banner1.jpg" /> 
</div>

That would be because of images being inlines and naturally having a little gap for dangly letters. Not all browsers show it, but you know you’ve got it if it goes away when you add this to your CSS:

img {
vertical-align: bottom; /should remove the gap/
}

You have labels in your form but you will want to link them to their inputs… you do this by making the “for” attribute of the labels match the ID’s of the inputs, not the names.


  <label for=[b]"name"[/b]>Name:<br/></label>
  <input type="text" name="username"  [b]id="name"[/b] />

Of course the rule still is that you only get to use a particular id once on a page… each must be unique.

You’ll want to style the anchor HOME at the bottom purely with external CSS (not the inline styles you have now) because inline (embedded) styles can’t do :hover and :focus, which you’ll want as a visual feedback for visitors.

Anyway, instead of your current CSS for #home you can center the child anchor like this


<div id="home">
<a href="index.html">Home</a>
</div>


#home {
  text-align: center;
}
#home a {
  color: #000;
}

the “a” will cover all states of “a” including “visited” so to make those different, you’d need to explicitly state them (which is what you want, less code) : )


<div id="flash" align="center">

Since align went away with the original Internet dot-bomb, use automargins instead.

If you know the width of #flash, state it… and you’ll be able to center it using automargins.

#flash {
position: relative; /you won’t need this if you let the form position itself/
width: whatever the width;
margin: 0 auto;
}

Width can be a % if you want.

Those are some ideas.

Wow, I just want to say you guys are a HUGE help and i really thank you for your time! I added the meta tag with the correct code (thank you and your assumption was correct :))and also corrected my labels for the form. Now that I’m seeing the end result Im realizing I completely threw everyone off by mistake(my apologies). I see now that the form stays in place when the browser is resized… I was actually resizing the size of the page with safari which made the box move to the right, not resizing the browser(pulling corner to make smaller). What I’m trying to achieve is having the box stay in sync with the page (so the opposite) and have it look the same in a different browser(IE,FF).

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html lang="ar">
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta http-equiv="content-language" content="nl">
    <title>My Title</title>

<head>


<style type="text/css">
body {
margin: 0;
}

#flash {
margin: 0 auto;
}

#home {
  text-align: center;
}
#home a {
  color: #000;
}


img {
vertical-align: bottom;
}

#form {
position: absolute; left: 400px; top: 550px;
}


</style>


</head>


<body>
<div style="text-align: center;"> 
<img src="new_banner1.jpg" /> 



</div>

<div style="text-align: center;"> 
<object type="application/x-shockwave-flash" data="contact.swf" width="800" height="1024">
   <param name="movie" value="contact.swf" />
   <param name="wmode" value="transparent" />
</object>
</div>

<div id="flash" align="center">
<div id="form">
  <form action="step2.php" method="post">
  <label for="name">Name:<br/></label>
  <input type="text" name = "username" id="name"/> <br/>
  <label for="email">Email:<br/></label>
  <input type="text" name = "emailaddy" id="email"/><br/>
  <label for="message">Message:<br/><textarea style="width: 200px; height: 100px;" row="20" cols = "100" name="message"></textarea><br/></label>
  <input type="submit" value="Send" id="message"/>
  </form>
  </div>


  

<div id="home">
<a href = "index.html">Home</a>
</div>

</body>


</html>


(thank you and your assumption was correct )

Ah, then you have a bit more work to do : ) And it won’t work on all browsers : (

(btw you left in “nl” as the language for the meta tag : ) I list lang in both places as supposedly some user agents checked the html attribute while others looked for a meta tag… and I assume that above all, the server overrides if it also sets a language)

You’ll want to set the direction in the html tag:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="ar" [b]dir="rtl"[/b]>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta http-equiv="content-language" content="ar">

This is supposed to tell the browsers to switch default settings like scrollbars, text direction and alignment, etc.

I’m not sure if it’s necessary but there’s a site I was helping debug recently who also had the direction on the body too:
<body dir=“rtl” >

It’s an attribute that you are supposed to be able to set on any element, though setting it on the html element is supposed to be good enough.

http://www.w3.org/TR/REC-html40/struct/dirlang.html

http://www.w3.org/TR/CSS2/visuren.html#direction

I’m not sure how well it actually works as far as CSS goes.

Anyway, you’ll find that Opera does it pretty well. Some of the other browsers, when the screen isn’t wide enough, will make a scrollbar, but in the wrong direction. So information further to the right may get lost. Check your site in as many browsers as possible, but don’t fret too much over like IE6 because there’s little you can do anyway.

Notes:
You’re still absolutely positioning your form, which I don’t think you need. It may be in the wrong place now that it’s still abso-po’d but doesn’t have a “positioned ancestor” (what your flash box was).

Flash can’t center with this alone:
#flash {
margin: 0 auto;
}

Automargins need a width to work. So, #flash needs a width.

The form, if it’s supposed to be centered inside the #flash, could do the same thing: have a width and automargined.

Top and bottom padding on #flash could simulate the look of the form being vertically centered as well (vertically centering stuff is a b**** in CSS, and there are tricks for it, but usually the goal is to make it look close-enough with the least amount of code, because I think it’s easy to go overboard with code for centering stuff).

Earlier I had run across some rtl bugs in Safari/Chrome (select drop-down boxes did not work in the right direction) but looking at a Farsi page recently in those browsers it seemed ok? So maybe that’s been fixed.

[ot]To clear up…:)[/ot]It doesn’t matter what element gets the dir attribute, it will cascade d own to the children (unless you override it of course)

Setting it to the body as well as HTML won’t have any effect at all considering the children could still inherit it from the HTML element.

It doesn’t matter what element gets the dir attribute, it will cascade d own to the children (unless you override it of course)

That’s how I figure it’s supposed to work, it’s just that I’ve seen plenty of bug reports in the past about the attribute not always working… so the suggestion to possibly add it to the body was more of a “may get around buggy implementations” rather than “the specs say”. But good to bring it up, browsers are getting better over time with rtl.

Esp Opera, can’t stress that one enough, did everything correct on the Farsi page I was debugging.

hey thanks again :slight_smile: Ill have someone test the rtl to get a better idea what will need to be modified. For the form I went ahead and changed it to relative positioning and it was placed below my home button. I tried to change the top and left attributes to 0 to see where it would place it and it positioned it at the bottom of the page, not within the page. I also tried adding a width to the #flash and it aligned the form to the right. I also tried moving the code for the form on top of the swf(or body of the page) but that just left a gap between the banner and swf.

Relative positioning should leave a gap. I rarely use it (for actual positioning).

Despite the name, relative positioning does not move something relative to some other box. Instead, when you put “position: relative” on a box, you’ve actually created another box! You don’t see it though, because it’s actually sitting right exactly on top of your old box, and holds the old box’s properties (background colours, images, borders, children). It’s like laying a new piece of paper over an old piece of paper.

When you start adding coordinates like left and top to a relatively positioned box, you’re moving the new box, but the old box is still sitting in the original place, taking up space. Sometimes people see this space and ask, how do I get rid of that unwanted extra space? Usually the answer is to use some other method of moving your box where you want it.

I don’t remember if you had posted a link, but could you either post a link to what you have now, or if it’s not yet online, post the code again? HTML and CSS? Then I can copy it and look at what you’ve got in my browser.

You still are going for that layout you posted earlier? I remember seeing a red area that you said would be a menu area… I don’t think I saw that in the code.

Anyway we can go through what’s happening if we see your current code. : )

Yes, im still aiming for the layout mentioned above with the different color codes. The red was the menu bar and the green and yellow are a text box with the form sitting within it. I dont have my code up just yet but added my most recent code below. Thanks again for helping me improve my code.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html lang="ar">
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta http-equiv="content-language" content="ar" dir="rtl">
    <title>My Title</title>

<head>


<style type="text/css">
body {
margin: 0;
}

#flash {
margin: 0 auto;
}

#home {
  text-align: center;
}
#home a {
  color: #000;
}


img {
vertical-align: bottom;
}


#form {
position: relative; left: 0px; top: 0px;
}
</style>



</head>


<body dir="rtl">
<div style="text-align: center;"> 
<img src="new_banner1.jpg" /> 



</div>

<div style="text-align: center;"> 
<object type="application/x-shockwave-flash" data="contact.swf" width="800" height="1024">
   <param name="movie" value="contact.swf" />
   <param name="wmode" value="transparent" />
</object>
</div>

<div id="flash" align="center">
<div id="form">
  <form action="step2.php" method="post">
  <label for="name">Name:<br/></label>
  <input type="text" name = "username" id="name"/> <br/>
  <label for="email">Email:<br/></label>
  <input type="text" name = "emailaddy" id="email"/><br/>
  <label for="message">Message:<br/><textarea style="width: 200px; height: 100px;" row="20" cols = "100" name="message"></textarea><br/></label>
  <input type="submit" value="Send" id="message"/>
  </form>
  </div>


<div id="home">
<a href = "index.html">Home</a>
</div>

</body>


</html>