Css position relative to image

I am trying to align email text and text box for it on top of the image in a specific place. I want the position to be fixed regardless of screen size. 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 can not get it to align with the image. Text and text box are not appropriate when viewing on a large screen or zooming in and out. Suggestion please.

+3
source share
2 answers

See my sample code. It works. Change the height of the parent div, the child will always stay below:

<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>
+2
source

, . . -, , .

 .Container {
position:relative

}

.child{
position:absolute
bottom:0px; // how much u wants to maintain..from the element
}
+1

Source: https://habr.com/ru/post/1771411/


All Articles