waleedd32
waleedd32

Reputation: 533

input drops down after zooming in and out

Here I made two simple input fields, but when I zoom in and zoom out on the page (Ctrl + Mouse wheel) somehow the input fields change places, input goes down and up, why it is doing this? How to have them at the same place whether I zoom in or out?

body {
  width: 870px;
}

#col3 {
  width: 400px;
  float: left;
  /*background-color:#383838;*/
  margin: 20px 10px 10px 30px;
}

form {
  width: 380px;
  margin: auto;
  padding: 5px;
  border: solid 1px white;
}

fieldset {
  margin: auto;
  border: solid 1px #E37222;
  padding-left: 19px;
  padding-top: 15px;
  background-color: #EEEEDD;
}

label {
  display: block;
  width: 70px;
  float: left;
  margin-left: 10px;
}

span {
  margin-left: -16px;
}

legend {
  background-color: #E37222;
  color: white;
}

input.tt {
  outline: 1px solid #909090;
}

.tt {
  margin-top: 8px;
}
<div id="col3">
  <form>
    <fieldset>
      <legend>eeeee</legend>

      <label for="name">
        <span>rrr:</span>
      </label>
      <input class="tt" type="text" size="34" />
      <br />

      <label class="tt" for="email">
        <span>ttt:</span>
      </label>
      <input class="tt" type="text" size="34" />

    </fieldset>
  </form>
</div>

..........................

Upvotes: 3

Views: 164

Answers (3)

PDSSandeep
PDSSandeep

Reputation: 189

Remove float:left for <label>

label{
    display:block;
    width:70px;
    margin-left:10px;

}

Upvotes: 2

Domenik Reitzner
Domenik Reitzner

Reputation: 1613

Either change your markup a little like that, or use flexbox/grid.

<style>

body{
width:870px;

}
#col3{
	width:400px;
	float:left;
	/*background-color:#383838;*/
	margin:20px 10px 10px 30px;

}
form{
	width:380px;
	margin:auto;
	padding:5px;
	border:solid 1px white;
}
fieldset{
	margin:auto;
	border:solid 1px #E37222;
	padding-left: 19px;
    padding-top: 15px;
	background-color:   #EEEEDD;
}

label{
	display:block;
    width: 100%;
}

label div{
    padding-right: 5px;
    width: 68px;
    display: inline-block;
}

legend{
background-color:#E37222;
color:white;
}


input.tt{
    outline: 1px solid #909090;
}
.tt{
    margin-top:8px;
}

</style>
</head>
<body>

<div id="col3">
	<form ">
	<fieldset >
			<legend>eeeee</legend>

			<label  for="name"><div>rrr:</div><input class="tt type="text" size="34" /> </label>
			
			<br/>		

			<label class="tt"for="email"><div>ttt:</div><input class="tt" type="text" size="34" /></label>
			
	
		
			
			
		
		</fieldset>
	</form>
	</div>
	
	
	
</body>
   

Upvotes: 1

PDSSandeep
PDSSandeep

Reputation: 189

Try with This

.youclassname{
 display:flex;
}

<div class="yourclassname">
  <label  for="name"><span>rrrrrr rrrrrr:</span></label>
  <input class="tt type="text" size="34" /> 
</div>

Upvotes: 1

Related Questions