tags:

views:

26

answers:

2

I am trying to align a text Email and textbox for it on top of an image at a specific location. I want the position to be fixed, no matter what size the screen is. Here is my html code:

<html>
<head>
<style type="text/css">
#container
{
background-color:blue;
}
#content
{
background: url('images/orange.jpg')  no-repeat center top;
}
#c_main
{
color: yellow;
}
#c_email
{
position:absolute;
top:200px;
left:410px;
color: #FFFFFF;
font-size: 15px;
}
#c_emailbox1
{
position:absolute;
top:200px;
left:480px;
}
#c_emailbox2
{
position:absolute;
top:200px;
left:620px;
color: white;
font-size: 12px;
}
input 
{
border:0;
}
.email_textbox1
{
width:130px;
background-image:url('images/text_bg.jpg');
background-repeat:no-repeat;
}
.email_textbox2
{
color: #FFFFFF;
font-size: 11px;
width:130px;
background-image:url('images/text_bg.jpg');
background-repeat:no-repeat;
}
</style>
</head>
<body>
<div id="container">
<div id="content" style="height:1000px;left:0px;border:1px solid red;position:relative" >
<div style="height:100px;width:200px;border:1px solid red;position:absolute;top:250px;left:0px">
<h4> CREATE A USERNAME AND PASSWORD </h4>
</div>
<div id="c_email">
Email
</div>
<div id="c_emailbox1">
<input type="textbox" id="email1" border="0" class="email_textbox1">
</div>
<div id="c_emailbox2">
<INPUT type="text" id ="email" value="Confirm Email Address" class="email_textbox2" onfocus="if
(this.value==this.defaultValue) this.value='';">
</div>
</div>
</div>
</body>
</html>

I cannot get it to align relative to the image. the text and textbox are misplaced when seen in a larger screen or if zoomed in and out. Suggestion please.

+1  A: 

Hi , If you want them always to the top of the text box. Make the parent control as relative. The box or anything which you want to maintain constant distance make it absolute position

 .Container {
position:relative

}

.child{
position:absolute
bottom:0px; // how much u wants to maintain..from the element
}
gov
I did try this...forgot to update code but it did not work. it still shows the same way
Scorpion King
can you please post your complete html , and add four white spaces while updateing , it will format properly.It should very simple.If you can update the html,we can easliy fix the problem
gov
This is my complete code. I am trying it on the local machine but not getting it to absolutely position itself.
Scorpion King
you should provide from parent element how much distance it has to maintain
gov
A: 

See my sample code..this is working. change the height of parent div , the child always stays at bottom

<div style="height:300px;border:1px solid red;position:relative"> 

   <div style="height:100px;width:20px;border:1px solid red;position:absolute;bottom:0px">                               </div>

    </div>
gov
hey gov, when you zoom in and zoom out... can you see the text going out of place. i do see that happening with the code which u provided. I want it to be relative to the image1.jpg that i am using... this seems to be relative to the full webpage.
Scorpion King
do you have your working copy of code anwhere?
gov
you mean a live link? if so then i do not have it right now.
Scorpion King
you gave a div height 1000px; with background url and within that div you have all the textboxes etc. Now from which image you want to maintain constant distance. As it is background image the div will have as that background.
gov
@scorpion , something wrong with the way you want to design. you gave image as background for image that is the problem. Create a div and plance image in the image < img scr= />
gov
the orange is the image on which i want the text to be relative to. http://i52.tinypic.com/1qixiw.png -- normal http://i56.tinypic.com/2cejdic.png -- zoomed in http://i52.tinypic.com/fkw555.png -- zoomed out
Scorpion King
Blue is just a background color... the orange one is the image and i want the text to be positioned based on that image and not based on the web browser or the blue background. I hope you get a better idea of what i am trying to achieve and i appreciate your effort in trying to help.
Scorpion King
Got it change your left postion to 0px; left:0px; to the parent it willwork, give all your textboxes etc left:0px;
gov
Yeah yellow container your parent container , if you want to maintain few pixes from top and left , you should top: 10px , left : 0px it always maintain that distance.
gov
ah... if i change all the divs of text and textboxes it goes relative to the blue background only.
Scorpion King
logically it should stay 0px from yellow div only.
gov
well it looks like it works when i use <img> tag inside the div and not as a background for the orange image. Thanks for your help gov.
Scorpion King