Web page layout appearing differently on different screens - html

I have designed my web page,
HTML code,
<div class="firstDiv"></div>
<div class="secondDiv"></div>
<div class="loginDiv">
<form>
<div class="row center">
<i class="fa fa-user-circle"></i>
</div>
<div class="container">
<input type="text" placeholder="Username" name="uname" required>
<input type="password" placeholder="Password" name="psw" required>
<br/>
<br/>
<button mat-button (click)="submit()">Login</button>
<br/>
<label>
<input type="checkbox" checked="checked" name="remember"> Remember me
</label>
</div>
</form>
</div>
CSS code,
#import '~#angular/material/theming';
#include mat-core();
$yaana-app-primary: mat-palette($mat-orange, 800,400,200);
.firstDiv {
height: 40%;
width: 100%;
top: 0;
left: 0;
right: 0;
position: absolute;
background-color: orangered;
display: inline-block;
}
.secondDiv {
position: absolute;
width: 100%;
bottom: 0;
height: 60%;
left: 0;
right: 0;
background-color:whitesmoke;
display: inline-block;
}
.loginDiv {
border: 1px solid black;
background: white;
left: 50%;
position: absolute;
top: 28%;
transform: translate(-50%);
background-color: #fff;
padding: 15px;
box-shadow:1px 3px 10px rgba(0, 0, 0, 0.34);
}
input[type=text], input[type=password] {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
box-sizing: border-box;
}
button {
width: 60%;
height: 20%;
line-height: 36px;
background: transparent;
border-radius: 3px;
will-change: transform;
-webkit-transition: all .2s ease;
transition: all .2s ease;
border: none;
/*border: 2px solid #FF5126;*/
cursor: pointer;
background: #F26722;
font-size: 16px;
color: #fff;
outline: none;
text-align: center;
padding: 0 6px;
margin: 6px 8px;
display: block;
margin: auto;
font-size: 14px;
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.26);
text-transform: uppercase !important;
}
button:hover {
opacity: 0.8;
}
.loginImgContainer {
display: table;
max-height: 40px;
max-width: 40px;
}
i.fa {
background: #fff;
display: inline-block;
font-size: 80px;
transform: translateY(-60%);
transform: translateX(160%);
border-radius: 50%;
margin: auto;
position: relative;
}
And when I run the web page I am getting different views,
1) For Desktop Browser
2) For small screens such as IPhone 6
3) For Ipad Pro,
I wanted the user icon to appear at centre but it is getting deviated from centre based on screen sizes.

Using a flexbox for the row that contains the circle. Documentation in the source.
/* Added display flex for circle row */
div.row.center {
display: flex;
justify-content: center;
width: 100%;
}
.firstDiv {
height: 40%;
width: 100%;
top: 0;
left: 0;
right: 0;
position: absolute;
background-color: orangered;
display: inline-block;
}
.secondDiv {
position: absolute;
width: 100%;
bottom: 0;
height: 60%;
left: 0;
right: 0;
background-color: whitesmoke;
display: inline-block;
}
.loginDiv {
border: 1px solid black;
background: white;
left: 50%;
position: absolute;
top: 28%;
transform: translate(-50%);
background-color: #fff;
padding: 15px;
box-shadow: 1px 3px 10px rgba(0, 0, 0, 0.34);
}
input[type=text],
input[type=password] {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
box-sizing: border-box;
}
button {
width: 60%;
height: 20%;
line-height: 36px;
background: transparent;
border-radius: 3px;
will-change: transform;
-webkit-transition: all .2s ease;
transition: all .2s ease;
border: none;
/*border: 2px solid #FF5126;*/
cursor: pointer;
background: #F26722;
font-size: 16px;
color: #fff;
outline: none;
text-align: center;
padding: 0 6px;
margin: 6px 8px;
display: block;
margin: auto;
font-size: 14px;
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.26);
text-transform: uppercase !important;
}
button:hover {
opacity: 0.8;
}
.loginImgContainer {
display: table;
max-height: 40px;
max-width: 40px;
}
i.fa {
background: #fff;
display: inline-block;
font-size: 80px;
/* transform: translateY(-60%); removed */
/* transform: translateX(160%); removed */
border-radius: 50%;
/* margin: auto; removed */
/* position: relative; removed */
}
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<div class="firstDiv"></div>
<div class="secondDiv"></div>
<div class="loginDiv">
<form>
<div class="row center">
<i class="fa fa-user-circle"></i>
</div>
<div class="container">
<input type="text" placeholder="Username" name="uname" required>
<input type="password" placeholder="Password" name="psw" required>
<br/>
<br/>
<button mat-button (click)="submit()">Login</button>
<br/>
<label>
<input type="checkbox" checked="checked" name="remember"> Remember me
</label>
</div>
</form>
</div>

try this for your circle div
position: absolute;
left: 0;
right: 0;
margin: auto;

Super easy to fix.
You have transforms on your circle for some reason see code:
i.fa {
background: #fff;
display: inline-block;
font-size: 80px;
/* transform: translateY(-60%); */
/* transform: translateX(160%); */
border-radius: 50%;
margin: auto;
position: relative;
}
Remove these 2 lines commented out and then add the following css:
.center {
text-align: center;
}

Related

How can i make my text be within a border & have the lines not be behind it?

I made a simple login screen, I just would like to know how i can get it to where login is in in the border but where i also dont see the border lines behind it. I've been trying to mess around with it and cant seem to figure it out. I also tried changing the background to see if it would do anything and nothing changed
.login-container {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
height: 400px;
width: 300px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
border: 1px solid rgba(255,255,255,0.1);
border-radius: 10px;
}
.login-container h1{
position: absolute;
top: 10px;
left: 0;
width: 100%;
text-align: center;
font-family: 'DM Sans', serif;
margin-top: -1.875rem;
color: #ffff;
font-size: 2.2rem;
}
.sign-in-btn,
.create-account-btn{
color: white;
padding: 10px 20px;
margin: 10px;
border-radius: 5px;
font-size: 16px;
width: 200px;
box-shadow: inset 0 0 0 0 #1db954;
transition: ease-out 0.3s;
background: none;
border: #1db954 solid 1px;
position: relative;
z-index: 1;
}
.sign-in-btn:hover,.create-account-btn:hover{
color: #FFFFFF;
background: #1db954;
}
.sign-in-btn:before,.create-account-btn:before{
transition: 0.5s all ease;
position: absolute;
top: 0;
left: 50%;
right: 50%;
bottom: 0;
opacity: 0;
content: "";
background-color: #1db954;
}
.sign-in-btn:hover:before,.create-account-btn:hover:before {
transition: 0.5s all ease;
left: 0;
right: 0;
opacity: 1;
z-index: -1;
}
<body>
<div class="form-container">
<h1>Sign in</h1>
<form>
<div class="form-input">
<input type="text" name="username" placeholder="Username" required>
</div>
<div class="form-input">
<input type="password" placeholder="Password" required>
</div>
<button type="submit" class="login-btn">Log in</button>
<p class="text">Dont have an account? Create an Account
Forgot Password?</p>
</form>
</div>
</body>
Ive read something about fieldset and legend, but cant seem to work it in my code
Here the example using background to hide the border line behind the element and text within border by connecting back all your CSS classes to respective html element.
.login-container {
height: 400px;
width: 300px;
border: 1px solid black;
border-radius: 10px;
background-color: lightgray;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.login-container h1 {
background-color: lightgray;
border: 1px solid black;
border-radius: 10px;
padding: 3px 6px;
position: absolute;
margin: 0;
top: -20px;
font-family: 'DM Sans', serif;
color: #ffff;
font-size: 2.2rem;
}
form {
text-align: center;
}
.sign-in-btn,
.create-account-btn {
color: white;
padding: 10px 20px;
margin: 10px;
border-radius: 5px;
font-size: 16px;
width: 200px;
box-shadow: inset 0 0 0 0 #1db954;
transition: ease-out 0.3s;
background: none;
border: #1db954 solid 1px;
position: relative;
z-index: 1;
}
.sign-in-btn:hover,
.create-account-btn:hover{
color: #FFFFFF;
background: #1db954;
}
.sign-in-btn:before,
.create-account-btn:before{
transition: 0.5s all ease;
position: absolute;
top: 0;
left: 50%;
right: 50%;
bottom: 0;
opacity: 0;
content: "";
background-color: #1db954;
}
.sign-in-btn:hover:before,
.create-account-btn:hover:before {
transition: 0.5s all ease;
left: 0;
right: 0;
opacity: 1;
z-index: -1;
}
<div class="login-container">
<h1>Sign in</h1>
<form>
<div class="form-input">
<input type="text" name="username" placeholder="Username" required>
</div>
<div class="form-input">
<input type="password" placeholder="Password" required>
</div>
<button type="submit" class="sign-in-btn">Log in</button>
<p class="create-account-btn">Dont have an account? Create an Account
Forgot Password?</p>
</form>
</div>

Extra Space in the bottom and right of the page

I am trying to make a login page but I don't know why there is a extra space in the bottom of the form and in mobile phone there is a extra space in the right. I have tried much but can't find any way to fix it.
I have also tried removing.
* {
margin: 0;
padding: 0;
}
As per this answer.
My code is as follows:
#import url('https://fonts.googleapis.com/css?family=Raleway:400,700');
* {
box-sizing: border-box;
margin: 0;
padding: 0;
font-family: Raleway, sans-serif;
}
body {
background: linear-gradient(90deg, #C7C5F4, #776BCC);
}
.container {
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
}
.screen {
background: linear-gradient(90deg, #5D54A4, #7C78B8);
position: relative;
height: 600px;
width: 360px;
box-shadow: 0px 0px 24px #5C5696;
}
.screen__content {
z-index: 1;
position: relative;
height: 100%;
}
.screen__background {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 0;
-webkit-clip-path: inset(0 0 0 0);
clip-path: inset(0 0 0 0);
}
.screen__background__shape {
transform: rotate(45deg);
position: absolute;
}
.screen__background__shape1 {
height: 520px;
width: 520px;
background: #FFF;
top: -50px;
right: 120px;
border-radius: 0 72px 0 0;
}
.screen__background__shape2 {
height: 220px;
width: 220px;
background: #6C63AC;
top: -172px;
right: 0;
border-radius: 32px;
}
.screen__background__shape3 {
height: 540px;
width: 190px;
background: linear-gradient(270deg, #5D54A4, #6A679E);
top: -24px;
right: 0;
border-radius: 32px;
}
.screen__background__shape4 {
height: 400px;
width: 200px;
background: #7E7BB9;
top: 420px;
right: 50px;
border-radius: 60px;
}
.login {
width: 320px;
padding: 30px;
padding-top: 156px;
}
.login__field {
padding: 20px 0px;
position: relative;
}
.login__icon {
position: absolute;
top: 30px;
color: #7875B5;
}
.login__input {
border: none;
border-bottom: 2px solid #D1D1D4;
background: none;
padding: 10px;
padding-left: 24px;
font-weight: 700;
width: 75%;
transition: .2s;
}
.login__input:active,
.login__input:focus,
.login__input:hover {
outline: none;
border-bottom-color: #6A679E;
}
.login__submit {
background: #fff;
font-size: 14px;
margin-top: 30px;
padding: 16px 20px;
border-radius: 26px;
border: 1px solid #D4D3E8;
text-transform: uppercase;
font-weight: 700;
display: flex;
align-items: center;
width: 100%;
color: #4C489D;
box-shadow: 0px 2px 2px #5C5696;
cursor: pointer;
transition: .2s;
}
.login__submit:active,
.login__submit:focus,
.login__submit:hover {
border-color: #6A679E;
outline: none;
}
.button__icon {
font-size: 24px;
margin-left: auto;
color: #7875B5;
}
.social-login {
position: absolute;
height: 140px;
width: 160px;
text-align: center;
bottom: 0px;
right: 0px;
color: #fff;
}
.social-icons {
display: flex;
align-items: center;
justify-content: center;
}
.social-login__icon {
padding: 20px 10px;
color: #fff;
text-decoration: none;
text-shadow: 0px 0px 8px #7875B5;
}
.social-login__icon:hover {
transform: scale(1.5);
}
<link href="https://use.fontawesome.com/releases/v5.2.0/css/fontawesome.css" rel="stylesheet" />
<link href="https://use.fontawesome.com/releases/v5.2.0/css/all.css" rel="stylesheet" />
<div class="container">
<div class="screen">
<div class="screen__content">
<form class="login">
<div class="login__field">
<i class="login__icon fas fa-user"></i>
<input type="text" class="login__input" placeholder="User name / Email">
</div>
<div class="login__field">
<i class="login__icon fas fa-lock"></i>
<input type="password" class="login__input" placeholder="Password">
</div>
<button class="button login__submit">
<span class="button__text">Log In Now</span>
<i class="button__icon fas fa-chevron-right"></i>
</button>
</form>
<div class="social-login">
<h3>log in via</h3>
<div class="social-icons">
</div>
</div>
</div>
<div class="screen__background">
<span class="screen__background__shape screen__background__shape4"></span>
<span class="screen__background__shape screen__background__shape3"></span>
<span class="screen__background__shape screen__background__shape2"></span>
<span class="screen__background__shape screen__background__shape1"></span>
</div>
</div>
</div>
Add overflow: hidden; to container. Your issue is due to the rotated elements taking space outside the container.
#import url('https://fonts.googleapis.com/css?family=Raleway:400,700');
* {
box-sizing: border-box;
margin: 0;
padding: 0;
font-family: Raleway, sans-serif;
}
body {
background: linear-gradient(90deg, #C7C5F4, #776BCC);
}
.container {
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
overflow: hidden;
}
.screen {
background: linear-gradient(90deg, #5D54A4, #7C78B8);
position: relative;
height: 600px;
width: 360px;
box-shadow: 0px 0px 24px #5C5696;
}
.screen__content {
z-index: 1;
position: relative;
height: 100%;
}
.screen__background {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 0;
-webkit-clip-path: inset(0 0 0 0);
clip-path: inset(0 0 0 0);
}
.screen__background__shape {
transform: rotate(45deg);
position: absolute;
}
.screen__background__shape1 {
height: 520px;
width: 520px;
background: #FFF;
top: -50px;
right: 120px;
border-radius: 0 72px 0 0;
}
.screen__background__shape2 {
height: 220px;
width: 220px;
background: #6C63AC;
top: -172px;
right: 0;
border-radius: 32px;
}
.screen__background__shape3 {
height: 540px;
width: 190px;
background: linear-gradient(270deg, #5D54A4, #6A679E);
top: -24px;
right: 0;
border-radius: 32px;
}
.screen__background__shape4 {
height: 400px;
width: 200px;
background: #7E7BB9;
top: 420px;
right: 50px;
border-radius: 60px;
}
.login {
width: 320px;
padding: 30px;
padding-top: 156px;
}
.login__field {
padding: 20px 0px;
position: relative;
}
.login__icon {
position: absolute;
top: 30px;
color: #7875B5;
}
.login__input {
border: none;
border-bottom: 2px solid #D1D1D4;
background: none;
padding: 10px;
padding-left: 24px;
font-weight: 700;
width: 75%;
transition: .2s;
}
.login__input:active,
.login__input:focus,
.login__input:hover {
outline: none;
border-bottom-color: #6A679E;
}
.login__submit {
background: #fff;
font-size: 14px;
margin-top: 30px;
padding: 16px 20px;
border-radius: 26px;
border: 1px solid #D4D3E8;
text-transform: uppercase;
font-weight: 700;
display: flex;
align-items: center;
width: 100%;
color: #4C489D;
box-shadow: 0px 2px 2px #5C5696;
cursor: pointer;
transition: .2s;
}
.login__submit:active,
.login__submit:focus,
.login__submit:hover {
border-color: #6A679E;
outline: none;
}
.button__icon {
font-size: 24px;
margin-left: auto;
color: #7875B5;
}
.social-login {
position: absolute;
height: 140px;
width: 160px;
text-align: center;
bottom: 0px;
right: 0px;
color: #fff;
}
.social-icons {
display: flex;
align-items: center;
justify-content: center;
}
.social-login__icon {
padding: 20px 10px;
color: #fff;
text-decoration: none;
text-shadow: 0px 0px 8px #7875B5;
}
.social-login__icon:hover {
transform: scale(1.5);
}
<link href="https://use.fontawesome.com/releases/v5.2.0/css/fontawesome.css" rel="stylesheet" />
<link href="https://use.fontawesome.com/releases/v5.2.0/css/all.css" rel="stylesheet" />
<div class="container">
<div class="screen">
<div class="screen__content">
<form class="login">
<div class="login__field">
<i class="login__icon fas fa-user"></i>
<input type="text" class="login__input" placeholder="User name / Email">
</div>
<div class="login__field">
<i class="login__icon fas fa-lock"></i>
<input type="password" class="login__input" placeholder="Password">
</div>
<button class="button login__submit">
<span class="button__text">Log In Now</span>
<i class="button__icon fas fa-chevron-right"></i>
</button>
</form>
<div class="social-login">
<h3>log in via</h3>
<div class="social-icons">
</div>
</div>
</div>
<div class="screen__background">
<span class="screen__background__shape screen__background__shape4"></span>
<span class="screen__background__shape screen__background__shape3"></span>
<span class="screen__background__shape screen__background__shape2"></span>
<span class="screen__background__shape screen__background__shape1"></span>
</div>
</div>
</div>
remove height: 140px; from .social-login class.
and if you talking about space after password then remove margin
#import url('https://fonts.googleapis.com/css?family=Raleway:400,700');
* {
box-sizing: border-box;
margin: 0;
padding: 0;
font-family: Raleway, sans-serif;
}
body {
background: linear-gradient(90deg, #C7C5F4, #776BCC);
}
.container {
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
}
.screen {
background: linear-gradient(90deg, #5D54A4, #7C78B8);
position: relative;
height: 600px;
width: 360px;
box-shadow: 0px 0px 24px #5C5696;
}
.screen__content {
z-index: 1;
position: relative;
height: 100%;
}
.screen__background {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 0;
-webkit-clip-path: inset(0 0 0 0);
clip-path: inset(0 0 0 0);
}
.screen__background__shape {
transform: rotate(45deg);
position: absolute;
}
.screen__background__shape1 {
height: 520px;
width: 520px;
background: #FFF;
top: -50px;
right: 120px;
border-radius: 0 72px 0 0;
}
.screen__background__shape2 {
height: 220px;
width: 220px;
background: #6C63AC;
top: -172px;
right: 0;
border-radius: 32px;
}
.screen__background__shape3 {
height: 540px;
width: 190px;
background: linear-gradient(270deg, #5D54A4, #6A679E);
top: -24px;
right: 0;
border-radius: 32px;
}
.screen__background__shape4 {
height: 400px;
width: 200px;
background: #7E7BB9;
top: 420px;
right: 50px;
border-radius: 60px;
}
.login {
width: 320px;
padding: 30px;
padding-top: 156px;
}
.login__field {
padding: 20px 0px;
position: relative;
}
.login__icon {
position: absolute;
top: 30px;
color: #7875B5;
}
.login__input {
border: none;
border-bottom: 2px solid #D1D1D4;
background: none;
padding: 10px;
padding-left: 24px;
font-weight: 700;
width: 75%;
transition: .2s;
}
.login__input:active,
.login__input:focus,
.login__input:hover {
outline: none;
border-bottom-color: #6A679E;
}
.login__submit {
background: #fff;
font-size: 14px;
margin-top: 30px;
padding: 16px 20px;
border-radius: 26px;
border: 1px solid #D4D3E8;
text-transform: uppercase;
font-weight: 700;
display: flex;
align-items: center;
width: 100%;
color: #4C489D;
box-shadow: 0px 2px 2px #5C5696;
cursor: pointer;
transition: .2s;
}
.login__submit:active,
.login__submit:focus,
.login__submit:hover {
border-color: #6A679E;
outline: none;
}
.button__icon {
font-size: 24px;
margin-left: auto;
color: #7875B5;
}
.social-login {
position: absolute;
width: 160px;
text-align: center;
bottom: 0px;
right: 0px;
color: #fff;
}
.social-icons {
display: flex;
align-items: center;
justify-content: center;
}
.social-login__icon {
padding: 20px 10px;
color: #fff;
text-decoration: none;
text-shadow: 0px 0px 8px #7875B5;
}
.social-login__icon:hover {
transform: scale(1.5);
}
<link href="https://use.fontawesome.com/releases/v5.2.0/css/fontawesome.css" rel="stylesheet" />
<link href="https://use.fontawesome.com/releases/v5.2.0/css/all.css" rel="stylesheet" />
<div class="container">
<div class="screen">
<div class="screen__content">
<form class="login">
<div class="login__field">
<i class="login__icon fas fa-user"></i>
<input type="text" class="login__input" placeholder="User name / Email">
</div>
<div class="login__field">
<i class="login__icon fas fa-lock"></i>
<input type="password" class="login__input" placeholder="Password">
</div>
<button class="button login__submit">
<span class="button__text">Log In Now</span>
<i class="button__icon fas fa-chevron-right"></i>
</button>
</form>
<div class="social-login">
<h3>log in via</h3>
<div class="social-icons">
</div>
</div>
</div>
<div class="screen__background">
<span class="screen__background__shape screen__background__shape4"></span>
<span class="screen__background__shape screen__background__shape3"></span>
<span class="screen__background__shape screen__background__shape2"></span>
<span class="screen__background__shape screen__background__shape1"></span>
</div>
</div>
</div>

overlapped when i minimize the screen

When i make the screen size smaller then the button and select option is getting overlapped as per the snippet. Inbetween the button and the select option there should be a inch gap (This output is coming when the screen is in maximized). can someone please help in this, should i add anything else for the output. Posting the html and css code below:
css:
body {
margin: 0;
padding: 0;
background: #262626;
}
h3
{
text-align: right;
color: #C0C0C0;
padding-top: 10px;
}
.box {
position: absolute;
top:40%;
left: 60%;
transform: translate(-50%, -50%);
}
.box1 {
position: absolute;
top: 50%;
left: 60%;
transform: translate(-50%, -50%);
}
.box2 {
position: absolute;
top: 60%;
left: 60%;
transform: translate(-50%, -50%);
}
.box select {
background: #a9a9a9;
color: #fff;
padding: 10px;
width: 250px;
height: 35px;
border: none;
font-size: 15px;
box-shadow: 0 5px 25px rgba(0,0,0,.5);
-webkit-appearance: border;
outline: none;
}
.box1 select {
background: #a9a9a9;
color: #fff;
padding: 10px;
width: 250px;
height: 35px;
border: none;
font-size: 15px;
box-shadow: 0 5px 25px rgba(0,0,0,.5);
-webkit-appearance: border;
outline: none;
}
.box2 select {
background: #a9a9a9;
color: #fff;
padding: 10px;
width: 250px;
height: 35px;
border: none;
font-size: 15px;
box-shadow: 0 5px 25px rgba(0,0,0,.5);
-webkit-appearance: border;
outline: none;
}
.ssystem
{
position: absolute;
top:40%;
left: 41%;
transform: translate(-50%, -50%);
background: #a9a9a9;
color: #fff;
padding: 10px;
width: 250px;
height: 35px;
border: none;
font-size: 15px;
box-shadow: 0 5px 25px rgba(0,0,0,.5);
-webkit-appearance: border;
outline: none;
}
.sub
{
position: absolute;
top:50%;
left: 41%;
transform: translate(-50%, -50%);
background: #a9a9a9;
color: #fff;
padding: 10px;
width: 250px;
height: 35px;
border: none;
font-size: 15px;
box-shadow: 0 5px 25px rgba(0,0,0,.5);
-webkit-appearance: border;
outline: none;
}
.subsub
{
position: absolute;
top:60%;
left: 41%;
transform: translate(-50%, -50%);
background: #a9a9a9;
color: #fff;
padding: 10px;
width: 250px;
height: 35px;
border: none;
font-size: 15px;
box-shadow: 0 5px 25px rgba(0,0,0,.5);
-webkit-appearance: border;
outline: none;
}
#button
{
background: #a9a9a9;
color: #fff;
position: absolute;
height:30px;
width:84px;
left:63%;
top:70%;
border: none;
color: arial;
font-size: 16px;
}
#button:hover
{
background: red;
cursor: pointer;
}
<body style="background-image: url(./img/bkgrnd.png);background-size: cover;">
<h3>welcome user!!</h3>
<button class="ssystem">System</button>
<button class="sub">Sub-System</button>
<button class="subsub">Sub-Sub-System</button>
<div class="box" id="sys">
<select>
<option>AAA</option>
<option>BBB</option>
<option>CCC</option>
</select>
</div>
<div class="box1" id="sub">
<select>
<option>AAA</option>
<option>BBB</option>
<option>CCC</option>
</select>
</div>
<div class="box2" id="sub1">
<select>
<option>AAA</option>
<option>BBB</option>
<option>CCC</option>
</select>
</div>
<input type="submit" value="Submit" id="button">
</body>
Rightnow no button is together with a select field and each element is positioned individually independent of each other sibling element. Sibling elements in this case are each button and the divs in which you find the select fields.
You can put the right button together with the right select field, this means you wrap them with a div and apply display: flex so they are positioned next to each other. For spacing you can add margin or padding.

Positioning the input form in the middle using margin: 0 auto not working

I'm trying to position the input form in the middle of form container using margin: 0 auto;, but not working.
I selected the div container and apply this:
.group {
position: relative;
top: 20px;
margin: 0 auto;
}
body {
background-color: Royalblue; /*#f0f0f0;*/
margin: 0px;
}
form {
position: relative;
top: 90px;
margin: 0 auto;
width: 280px;
height: 340px;
border: 1px solid #B0C4DE;
background: royalblue;
border-radius: 0px;
border-radius: 10px 10px 10px 10px;
}
/* Main EFFECT ================================ */
input {
position: relative;
top: 0px;
left: 0px;
font-family: 'Montserrat', sans-serif;
border: 0;
border-bottom: 1px solid white;
background: transparent;
font-size: 15px;
height: 25px;
width: 180px;
outline: 0;
z-index: 1;
color: black;
}
label {
display: block;
}
span {
position: absolute;
top: 7px;
left: 0px;
font-family: 'Montserrat', sans-serif;
font-size: 13px;
z-index: 1;
color: white;
transition: top .5s ease, font-size .5s ease;
}
.group {
position: relative;
top: 20px;
margin: 0 auto;
}
/*
label::after {
content: '';
position: absolute;
top: 5px;
left: 0px;
width: 200px;
height: 23px;
border-radius: 2px;
background: beige;
transition: transform .7s;
transform: scale3d(1, 0.1, 1);
transform-origin: bottom;
}
*/
/*
input:focus + label::after {
top: 5px;
transform: scale3d(1, 1.2, 1);
transition-timing-function: linear;
}
input:focus + label > span {
top: -20px;
font-size: 10px;
}
*/
<body>
<form>
<div class="group">
<input class="input1" type="email" id="email" required />
<label class="label1" for="email">
<span class="sp1">Email</span>
</label>
</div>
</form>
</body>
without width browser can not calculate how much margins it will put to left/right
you can see here in your case decrease width
http://prntscr.com/kvqscq
body {
background-color: Royalblue; /*#f0f0f0;*/
margin: 0px;
}
form {
position: relative;
top: 90px;
margin: 0 auto;
width: 280px;
height: 340px;
border: 1px solid #B0C4DE;
background: royalblue;
border-radius: 0px;
border-radius: 10px 10px 10px 10px;
}
/* Main EFFECT ================================ */
input {
position: relative;
top: 0px;
left: 0px;
font-family: 'Montserrat', sans-serif;
border: 0;
border-bottom: 1px solid white;
background: transparent;
font-size: 15px;
height: 25px;
width: 180px;
outline: 0;
z-index: 1;
color: black;
}
label {
display: block;
}
span {
position: absolute;
top: 7px;
left: 0px;
font-family: 'Montserrat', sans-serif;
font-size: 13px;
z-index: 1;
color: white;
transition: top .5s ease, font-size .5s ease;
}
.group {
position: relative;
top: 20px;
margin: 0 auto;
width: max-content;
}
/*
label::after {
content: '';
position: absolute;
top: 5px;
left: 0px;
width: 200px;
height: 23px;
border-radius: 2px;
background: beige;
transition: transform .7s;
transform: scale3d(1, 0.1, 1);
transform-origin: bottom;
}
*/
/*
input:focus + label::after {
top: 5px;
transform: scale3d(1, 1.2, 1);
transition-timing-function: linear;
}
input:focus + label > span {
top: -20px;
font-size: 10px;
}
*/
<body>
<form>
<div class="group">
<input class="input1" type="email" id="email" required />
<label class="label1" for="email">
<span class="sp1">Email</span>
</label>
</div>
</form>
</body>
Give your .group class below css, and you're all set...
.group {
width: max-content;
}
Now label will also move into center...
try this
.sp1{
left : 70px;
}

Prevent icons inside div from collapsing to inside other div

So using HTML, CSS and Bootstrap, i have 4 icons on the left side of the wrapper, where they are organize similar to a square. But when i resize the window, those icons collapse behind a console that i have below. How can i prevent this from happening(would be nice to keep the buttons in the same position)?
Here's the code for the CSS and the HTML
#designContainer {
display: none;
background-color: #fff;
position: absolute;
bottom: 40px;
top: 120px;
left: 10%;
/*width of toolbar*/
margin-left: 38px;
/*margin of toolbar*/
right: 20px;
overflow: hidden;
border: 1px solid #003399;
/* border-top:3px solid #FFCC00; */
z-index: 10;
cursor: crosshair;
}
#toolsWrapper {
display: none;
background-color: #fff;
position: absolute;
bottom: 40px;
top: 120px;
left: 20px;
width: 10%;
overflow: hidden;
z-index: 11;
margin-bottom: 0;
}
#toolsWrapper label img {
position: relative;
width: 30px;
height: auto;
margin: 10px 0px;
opacity: 0.3;
transition: 0.2s;
}
#toolsWrapper [type=radio] {
position: absolute;
opacity: 0;
width: 0;
height: 0;
}
/* IMAGE STYLES */
#toolsWrapper [type=radio]+img {
cursor: pointer;
}
/* CHECKED STYLES */
#toolsWrapper [type=radio]:checked+img {
opacity: 1;
}
#toolsWrapper [type=radio]:checked+img:hover {
opacity: 1;
}
#toolsWrapper [type=radio]+img:hover {
opacity: 0.7;
}
#sideToolButtons {
margin-bottom: 20px;
}
#sideToolButtons button {
outline: none;
width: 20px;
height: auto;
margin: 0;
padding: 0;
border: 0;
background: none;
cursor: pointer;
}
#sideToolButtons button:hover>img {
opacity: 1;
}
#sideToolButtons button>img {
width: 100%;
height: 100%;
opacity: 0.7;
}
#sideToolButtons .btn_disabled img {
opacity: 0.2;
cursor: default;
}
#sideToolButtons .btn_disabled:hover>img {
opacity: 0.2;
cursor: default;
}
#calcButton {
position: absolute;
bottom: 50px;
width: 30px !important;
right: 50%;
margin-right: -10px !important;
display: none;
}
#designConsole {
width: 100%;
position: absolute;
bottom: 0;
height: 60%;
min-height: 180px;
margin-bottom: 0;
}
#innerConsole {
position: relative;
color: #333;
height: 100%;
min-height: 40px;
font-size: 9pt;
border: #002774 1px solid;
overflow: hidden;
padding: 3px 6px;
}
#innerConsole:hover {
overflow: auto;
}
#innerConsole>p {
margin: 0;
padding: 0 !important;
text-align: left;
margin-bottom: 5px !important;
}
.lastEntry {
font-weight: bold;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<fieldset class="step">
<legend id="stepTitle_2">Line Design</legend>
<div id="stepDesc_2" class="txtbox">
Make a sketch of the required line design. The composition and length of the channels are visible if you draw or adapt the line.
</div>
<div id="toolsWrapper" class="form-group">
<label id='drawtoggle' class="col-md-3">
<input type="radio" id="penToggle" name="mouseToggle" value=0 checked>
<img src="./images/draw.png">
</label>
<label id='cursortoggle' class="col-md-3">
<input type="radio" id="selToggle" name="mouseToggle" value=1>
<img src="./images/cursor.png">
</label>
<div id="sideToolButtons" class="form-group">
<button type="button" id="delButton" class="col-md-6" style="margin-left: 20px;">
<img src="./images/trash.png" alt=""/>
</button>
<button type="button" id="zoomFitButton" class="col-md-6" style="margin-left: 20px;">
<img src="./images/zoom_fit.png" alt=""/>
</button>
</div>
<div id="designConsole" class="form-group">
<!-- <div id="designDefinitions" class = "col-md-6"></div> -->
<div id="innerConsole" class="col-md-12"></div>
</div>
</div>
<div id="designContainer"></div>
</fieldset>
Thank you.