can someone help rectify an issue I am facing. I am trying to set a space between two divs but doing this moves both divs together. My code is as follows:
@charset "utf-8";
/* CSS Document */
* {
box-sizing: border box;
}
body {
background-image: url(../images/nature_beach-1280x800.jpg);
background-repeat: no-repeat;
background-size: 100% 100%;
height: 100%;
margin: 0;
}
html {
height: 100%;
}
#container {
background-color: rgba(255, 255, 255, .50);
height: 65%;
width: 30%;
box-sizing: border-box;
transform: translate(200%, 20%);
font-family: Myriad Pro;
font-size: 20px;
}
#login {
text-align: center;
padding: 5%;
font-weight: bold;
}
#form {
margin-top: 5%;
margin-left: 10%;
}
.textfield {
height: 25px;
width: 250px;
background-color: rgba(109, 207, 246, .50);
border: none;
}
.fieldname {
float: left;
}
.textbox {
float: right;
margin-right: 10%
}
#container2 {
/*What should I put here??*/
}
<div id="container">
<div id="login">
Login
</div>
<div id="form">
<div id="container1">
<span class="fieldname">Username</span>
<span class="textbox"><input class="textfield" type="text" /></span>
</div>
<div id="container2">
<span class="fieldname">Password</span>
<span class="textbox"><input class="textfield" type="text" /></span>
</div>
</div>
</div>
When I set margin-top:5% to container2 in css, both divs move according to the margin. What I want to do is variable space between the two divs. Padding to container2 messes up the layout.
Please help me out.