Extra Space in the bottom and right of the page - html

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>

Related

Layering 3+ HTML objects

How do you layer Multiple layers of HTML objects in CSS? My code is broken
Is there an easier way of doing this?
So in my project there is the main canvas, then an "inventory"-div-table in it with interactive cells each layered with div's and images but I'm trying to get a p-tag to layer over the cells image to represent the quantity of thus item my code is as follows:
html, body {
background: lightslategray;
width: 100%;
height: 100%;
margin: 0px;
padding: 0px;
}
#pengame {
position: relative;
width: 100%;
height: 100%;
}
#pengame canvas {
position: absolute;
image-rendering: auto;
object-fit: none;
}
#ingamechat{
position: absolute;
top: 62%;
left: 50%;
transform: translate(-50%, -50%);
display: none;
}
#leaderboard{
position: absolute;
display: none;
top: 1.8%;
right: 100px;
background: rgb(50,50,50,0.4);
border-radius: 10px;
color: white;
}
#inventory{
position: absolute;
display: block;
top: 10%;
left: calc(1.3% + 320px);
background: rgb(50,50,50,0.4);
border-radius: 10px;
color: white;
padding: 0px 15px;
width: 300px;
max-width: 400px;
height: 70%;
max-height: 70%;
overflow: scroll;
-webkit-user-select: none;
}
.td{
padding:5px;
position: relative;
max-width: 55px;
max-height: 55px;
}
input[type=text] {
width: 100%;
padding: 4px 5px;
box-sizing: border-box;
color: white;
opacity: 0.5;
background: transparent;
border: none;
}
input:focus {
outline: none;
}
#infobox{
position: absolute;
display: block;
top: 1.8%;
left:1%;
max-width: 300px;
background: rgb(50,50,50,0.4);
padding: 0px 10px;
border-radius: 25px;
color: white;
}
#boption{
height: 35px;
width: 35px;
padding: 5px 4px;
border-radius: 10px;
-webkit-user-select: none;
}
#shopicon{
position: absolute;
display: block;
top: 1.8%;
right: 15px;
background: rgb(50,50,50,0.4);
border-radius: 10px;
}
#shopicon :hover{
position: absolute;
display: block;
top: 1.8%;
right: 0%;
background: rgb(200,200,200,0.4);
border-radius: 10px;
}
#invetoryitem{
--displayc: rgb(50,200,50,0.4);
display: block;
background: rgb(50,50,50,0.4);
height: 45px;
width: 45px;
padding: 5px 4px;
border-radius: 10px;
}
#invetorypic{
height: 45px;
width: 45px;
}
#invetoryitem :hover{
background: rgb(200,200,200,0.4);
border-radius: 10px;
}
#invnumber{
display: block;
position: absolute;
color: black
}
canvas {
background-color: transparent;
}
<div id="pengame">
<div id="inventory">
<h2>Inventory</h2>
<table id="myitems">
<tr>
<td>
<div id="invetoryitem" > <img id="invetorypic" src="https://www.gdrc.psychol.cam.ac.uk/images/apple/image"/></div> <p id="invnumber">1</p>
</td>
</tr>
</table>
</div>
</div>
This code is a good representation of what my "inventory" looks like
Improving the HTML
I'm going to focus solely on the inventory area, and not the overall layout of the page, which probably warrants its own aide. Here are some important details about the following code:
Consider using a ul instead of a table. You are representing a list of items so the ul makes the most semantic sense here
Use flexbox for the layout of the list and its items
Since you want the inventory stock number on top of the image (lower right), you must first create a relative container in which to absolutely place them. We'll set each li to position: relative
#inventory-items {
display: flex;
list-style: none;
flex-wrap: wrap;
margin: 0;
padding: 0;
width: 300px;
background-color: rgba(0, 0, 0, .2);
}
.inventory-item {
position: relative;
border: 1px solid transparent;
}
.inventory-stock {
position: absolute;
bottom: 5px;
right: 0;
z-index: 1;
background-color: rgba(0, 0, 0, .7);
color: white;
display: inline-block;
padding: 1px 2px;
text-align: center;
font-size: 90%;
}
.invetory-pic {
max-width: 50px;
}
<div id="inventory">
<h2>Inventory</h2>
<ul id="inventory-items">
<li class="inventory-item">
<img class="invetory-pic" src="https://www.gdrc.psychol.cam.ac.uk/images/apple/image" / alt="">
<span class="inventory-stock">1</span>
</li>
<li class="inventory-item">
<img class="invetory-pic" src="https://www.gdrc.psychol.cam.ac.uk/images/apple/image" / alt="">
<span class="inventory-stock">5</span>
</li>
<li class="inventory-item">
<img class="invetory-pic" src="https://www.gdrc.psychol.cam.ac.uk/images/apple/image" / alt="">
<span class="inventory-stock">121</span>
</li>
<li class="inventory-item">
<img class="invetory-pic" src="https://www.gdrc.psychol.cam.ac.uk/images/apple/image" / alt="">
<span class="inventory-stock">1000</span>
</li>
<li class="inventory-item">
<img class="invetory-pic" src="https://www.gdrc.psychol.cam.ac.uk/images/apple/image" / alt="">
<span class="inventory-stock">10</span>
</li>
<li class="inventory-item">
<img class="invetory-pic" src="https://www.gdrc.psychol.cam.ac.uk/images/apple/image" / alt="">
<span class="inventory-stock">5</span>
</li>
<li class="inventory-item">
<img class="invetory-pic" src="https://www.gdrc.psychol.cam.ac.uk/images/apple/image" / alt="">
<span class="inventory-stock">5</span>
</li>
<li class="inventory-item">
<img class="invetory-pic" src="https://www.gdrc.psychol.cam.ac.uk/images/apple/image" / alt="">
<span class="inventory-stock">5</span>
</li>
</ul>
</div>
jsFiddle
Working with the existing HTML
To leave your code mostly as it is, and make the additions you want:
convert the ids to classes (duplicate ids are invalid HTML)
Move the inventory number inside the container containing the image
html,
body {
background: lightslategray;
width: 100%;
height: 100%;
margin: 0px;
padding: 0px;
}
#pengame {
position: relative;
width: 100%;
height: 100%;
}
#pengame canvas {
position: absolute;
image-rendering: auto;
object-fit: none;
}
#ingamechat {
position: absolute;
top: 62%;
left: 50%;
transform: translate(-50%, -50%);
display: none;
}
#leaderboard {
position: absolute;
display: none;
top: 1.8%;
right: 100px;
background: rgb(50, 50, 50, 0.4);
border-radius: 10px;
color: white;
}
#inventory {
position: absolute;
display: block;
top: 10%;
left: calc(1.3% + 320px);
background: rgb(50, 50, 50, 0.4);
border-radius: 10px;
color: white;
padding: 0px 15px;
width: 300px;
max-width: 400px;
height: 70%;
max-height: 70%;
overflow: scroll;
-webkit-user-select: none;
}
.td {
padding: 5px;
position: relative;
max-width: 55px;
max-height: 55px;
}
input[type=text] {
width: 100%;
padding: 4px 5px;
box-sizing: border-box;
color: white;
opacity: 0.5;
background: transparent;
border: none;
}
input:focus {
outline: none;
}
#infobox {
position: absolute;
display: block;
top: 1.8%;
left: 1%;
max-width: 300px;
background: rgb(50, 50, 50, 0.4);
padding: 0px 10px;
border-radius: 25px;
color: white;
}
#boption {
height: 35px;
width: 35px;
padding: 5px 4px;
border-radius: 10px;
-webkit-user-select: none;
}
#shopicon {
position: absolute;
display: block;
top: 1.8%;
right: 15px;
background: rgb(50, 50, 50, 0.4);
border-radius: 10px;
}
#shopicon :hover {
position: absolute;
display: block;
top: 1.8%;
right: 0%;
background: rgb(200, 200, 200, 0.4);
border-radius: 10px;
}
.invetoryitem {
--displayc: rgb(50, 200, 50, 0.4);
display: block;
background: rgb(50, 50, 50, 0.4);
height: 45px;
width: 45px;
padding: 5px 4px;
border-radius: 10px;
}
.invetorypic {
height: 45px;
width: 45px;
}
.invetoryitem :hover {
background: rgb(200, 200, 200, 0.4);
border-radius: 10px;
}
canvas {
background-color: transparent;
}
.invetoryitem {
position: relative;
}
.invnumber {
position: absolute;
bottom: -12px;
right: 4px;
color: black;
pointer-events: none;
}
<div id="pengame">
<div id="inventory">
<h2>Inventory</h2>
<table id="myitems">
<tr>
<td>
<div class="invetoryitem"> <img class="invetorypic" src="https://www.gdrc.psychol.cam.ac.uk/images/apple/image" />
<p class="invnumber">1</p>
</div>
</td>
</tr>
<tr>
<td>
<div class="invetoryitem"> <img class="invetorypic" src="https://www.gdrc.psychol.cam.ac.uk/images/apple/image" />
<p class="invnumber">21</p>
</div>
</td>
</tr>
</table>
</div>
</div>
jsFiddle

Web page layout appearing differently on different screens

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;
}

CSS before in the wrong place

I have a problem in the before of a div. I'm trying to position it at first, but it's going to the beginning of the parent div on the other side. What can I be doing wrong?
Html:
.cart-item.free-delivery-warn .left {
width: 55%;
height: 100%;
display: inline-block;
}
.cart-item.free-delivery-warn .left p {
text-align: right;
background: linear-gradient(to right, #543a5c, #452f4b);
color: #fff;
padding: 10px 0;
padding-right: 40px;
}
.cart-item.free-delivery-warn .right-content {
width: 45%;
height: 100%;
float: right;
}
.cart-item.free-delivery-warn .right-content p {
background: #bf2328;
text-align: left;
padding: 10px 0 13px 10px;
font-weight: 500;
color: #fff;
}
.right-content:before {
position: absolute;
bottom: 0;
right: 100%;
left: -12px;
content: "";
width: 0;
height: 0;
border-style: solid;
border-width: 20px 12px 22px 0;
border-color: transparent #bf2328 transparent transparent;
}
<div class="cart-item free-delivery-warn">
<div class="left">
<p>Faltam apenas <span class="price-w">R$ 165,00</span> para você ganhar</p>
</div>
<div class="right-content">
<p>Frete grátis <i class="fa fa-truck price-w"></i></p>
</div>
</div>
and what it's doing wrong:
Whenever you use position: absolute and you want it to be relative to the container, you need to set the container to position: relative. Like this:
.cart-item.free-delivery-warn .left {
width: 55%;
height: 100%;
display: inline-block;
}
.cart-item.free-delivery-warn .left p {
text-align: right;
background: linear-gradient(to right, #543a5c,#452f4b);
color: #fff;
padding: 10px 0;
padding-right: 40px;
}
.cart-item.free-delivery-warn .right-content {
width: 45%;
height: 100%;
float: right;
}
.cart-item.free-delivery-warn .right-content p {
background: #bf2328;
text-align: left;
padding: 10px 0 13px 10px;
font-weight: 500;
color: #fff;
}
.right-content {
position: relative;
}
.right-content:before {
position: absolute;
bottom: 0;
right: 100%;
left: -12px;
content: "";
width: 0;
height: 0;
border-style: solid;
border-width: 20px 12px 22px 0;
border-color: transparent #bf2328 transparent transparent;
}
<div class="cart-item free-delivery-warn">
<div class="left">
<p >Faltam apenas <span class="price-w">R$ 165,00</span> para você ganhar</p>
</div>
<div class="right-content">
<p>Frete grátis <i class="fa fa-truck price-w"></i></p>
</div>
</div>
You're so close, but you're just missing a position: relative on the parent.
Just be careful as margin will push it out of alignment.
Try this out:
body {
box-sizing: border-box;
}
p {
margin: 0;
}
.cart-item.free-delivery-warn .left {
width: 55%;
height: 100%;
display: inline-block;
}
.cart-item.free-delivery-warn .left p {
text-align: right;
background: linear-gradient(to right, #543a5c, #452f4b);
color: #fff;
padding: 10px 0;
padding-right: 40px;
}
.cart-item.free-delivery-warn .right-content {
width: 45%;
height: 100%;
float: right;
position: relative;
}
.cart-item.free-delivery-warn .right-content p {
background: #bf2328;
text-align: left;
padding: 10px 0 13px 10px;
font-weight: 500;
color: #fff;
}
.right-content:before {
position: absolute;
bottom: 0;
right: 100%;
left: -12px;
content: "";
width: 0;
height: 0;
border-style: solid;
border-width: 20px 12px 22px 0;
border-color: transparent #bf2328 transparent transparent;
}
<div class="cart-item free-delivery-warn">
<div class="left">
<p>Faltam apenas <span class="price-w">R$ 165,00</span> para você ganhar</p>
</div>
<div class="right-content">
<p>Frete grátis <i class="fa fa-truck price-w"></i></p>
</div>
</div>

link with icon in header alignment

My header is devided in 3 sections: left, center and right. The left section is empty. In the center section I have my page title and in the right section I placed an "Account" link with an icon next to it. The link contains the word ACCOUNT and an icon. the icon is somehow pushed to the top and leaves a blank space below it next to the word. I want them both in one line and on the same hight. How can I achieve this? I added a red background to make the problem better understandable.
html {
height: 100%;
box-sizing: border-box;
overflow: hidden;
}
*,
*:before,
*:after {
box-sizing: inherit;
overflow: inherit;
}
body {
background-color: #f5f5f5;
margin: 0;
padding: 0;
position: relative;
height: 100%;
}
#in {
width: 1000px;
margin-left: auto;
margin-right: auto;
height: 100%;
}
/* ------------------------------------------------------------------------ */
/* -------------------------------- HEADER -------------------------------- */
/* ------------------------------------------------------------------------ */
header {
background-color: #131b23;
border-bottom: 6px solid #0f151a;
text-align: center;
left: 0;
top: 0;
width: 100%;
height: 170px;
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
z-index: 99;
}
#left {
background-color: green;
width: 20%;
position: absolute;
height: 164px;
}
#center {
background-color: red;
width: 60%;
margin-left: auto;
margin-right: auto;
height: 100%;
position: absolute;
left: 20%;
right: 20%;
height: 164px;
}
#right {
background-color: blue;
width: 20%;
height: 100%;
position: absolute;
right: 0;
height: 164px;
}
#heading {
font-size: 60px;
display: block;
margin-bottom: -7px;
margin-top: 15px;
}
.accountlink {
font-family: "Helvetica";
text-decoration: none;
font-weight: 800;
color: #ffffff;
font-size: 13px;
letter-spacing: 1px;
text-transform: uppercase;
background-color: red;
position: absolute;
right: 30px;
top: 15px;
}
.navigationicon {
position: relative;
width: 24px;
margin: 0;
padding: 0;
top: 50%;
bottom: 50%;
}
<header>
<div id="left">
</div>
<div id="center">
<h1 id="heading">My Page</h1>
</div>
<div id="right">
<a class="accountlink" href="login.html">Account <img class="navigationicon" src="https://cdn2.iconfinder.com/data/icons/ios-7-icons/50/user_male2-512.png"></a>
</div>
</header>
Can you check this ?
html {
height: 100%;
box-sizing: border-box;
overflow: hidden;
}
*,
*:before,
*:after {
box-sizing: inherit;
overflow: inherit;
}
body {
background-color: #f5f5f5;
margin: 0;
padding: 0;
position: relative;
height: 100%;
}
#in {
width: 1000px;
margin-left: auto;
margin-right: auto;
height: 100%;
}
/* ------------------------------------------------------------------------ */
/* -------------------------------- HEADER -------------------------------- */
/* ------------------------------------------------------------------------ */
header {
background-color: #131b23;
border-bottom: 6px solid #0f151a;
text-align: center;
left: 0;
top: 0;
width: 100%;
height: 170px;
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
z-index: 99;
}
#left {
background-color: green;
width: 20%;
position: absolute;
height: 164px;
}
#center {
background-color: red;
width: 60%;
margin-left: auto;
margin-right: auto;
height: 100%;
position: absolute;
left: 20%;
right: 25%;
height: 164px;
}
#right {
background-color: blue;
width: 20%;
height: 100%;
position: absolute;
right: 0;
height: 164px;
}
#heading {
font-size: 60px;
display: block;
margin-bottom: -7px;
margin-top: 15px;
}
.accountlink {
font-family: "Helvetica";
text-decoration: none;
font-weight: 800;
color: #ffffff;
font-size: 13px;
letter-spacing: 1px;
text-transform: uppercase;
background-color: white;
position: absolute;
left: 50px;
top: 20px;
background: url("https://cdn2.iconfinder.com/data/icons/ios-7-icons/50/user_male2-512.png");
background-size: 24px;
background-repeat: no-repeat;
background-position-x: right;
background-position-y: 0px;
width: 40%;
line-height: 2;
}
<header>
<div id="left">
</div>
<div id="center">
<h1 id="heading">My Page</h1>
</div>
<div id="right">
<a class="accountlink" href="login.html">Account </a>
</div>
</header>
Four changes to your css code to get there: 2 at .navigationicon and 2 at .accountlink
.accountlink {
font-family: "Helvetica";
text-decoration: none;
font-weight: 800;
color: #ffffff;
font-size: 13px;
letter-spacing: 1px;
text-transform: uppercase;
background-color: red;
position: absolute;
right: 80px;
top: 70px;
}
.navigationicon {
position: relative;
width: 12px;
margin: 0 0 2px -5px;
padding: 0;
top: 50%;
bottom: 50%;
}

How to align a window on right side with flexible height?

Hey!
As you see in the picture I want to move the existing chatwindow to the right side where the red box is.
And I also need the box to change the height of itself when the window is made smaller.
The grid is from semantic.ui.
EDIT: On some request the whole css and parent html container is given. Hope this helps to solve the problem.
Thanks!
HTML:
<div class="two column doubling ui grid">
<div class="column">
<div class="ui segment">
1
</div>
</div>
<div class="computer only column">
<div class="chat_window">
<div class="top_menu">
<div class="buttons">
<div class="button maximize">
<h4 id="Online"></h4>
</div>
</div>
<div class="title">Chat</div>
</div>
<ul class="messages"></ul>
<div class="bottom_wrapper clearfix">
<div class="message_input_wrapper"><input class="message_input" placeholder="Type your message!" /></div>
<div class="send_message">
<div class="text">Send</div>
</div>
</div>
</div>
<div class="message_template">
<li class="message">
<div class="avatar"></div>
<div class="text_wrapper">
<div class="msgname"><a id="steamlink" target="_blank"><p id="msgname"></p></a></div>
<div class="text"></div>
</div>
</li>
</div>
</div>
</div>
CSS:
.chat_window {
width: 100%;
max-width: 450px;
background-color: #fff;
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
background-color: #f8f8f8;
overflow: hidden;
}
.top_menu {
background-color: #fff;
width: 100%;
padding: 20px 0 15px;
box-shadow: 0 1px 30px rgba(0, 0, 0, 0.1);
}
.top_menu .buttons {
margin: 3px 0 0 20px;
position: absolute;
}
.top_menu .buttons .button {
width: 16px;
height: 16px;
border-radius: 50%;
display: inline-block;
margin-right: 10px;
position: relative;
}
.top_menu .buttons .button.close {
background-color: #f5886e;
}
.top_menu .buttons .button.minimize {
background-color: #fdbf68;
}
.top_menu .buttons .button.maximize {
background-color: #a3d063;
}
.top_menu .title {
text-align: center;
color: #bcbdc0;
font-size: 20px;
}
#Online{
margin: 0 0 0 20px;
color: #bcbdc0;
}
.messages {
position: relative;
list-style: none;
padding: 20px 10px 0 10px;
margin: 0;
height: 600px;
overflow-y: scroll;
}
.messages .message {
clear: both;
overflow: hidden;
margin-bottom: 10px;
transition: all 0.5s linear;
opacity: 0;
}
.messages .message.left .avatar {
background-size: 100%;
float: left;
}
.messages .message.left .text_wrapper {
background-color: #DFDFDF;
margin-left: 20px;
}
.messages .message .avatar {
width: 60px;
height: 60px;
border-radius: 50%;
display: inline-block;
}
.messages .message .msgname {
font-weight: bold;
}
.messages .message .text_wrapper {
display: inline-block;
padding-left: 10px;
padding-top: 5px;
padding-bottom: 5px;
border-radius: 6px;
width: calc(100% - 85px);
min-width: 100px;
position: relative;
}
.messages .message .text_wrapper .text {
font-size: 14px;
font-weight: 250;
}
.bottom_wrapper {
position: relative;
width: 100%;
background-color: #fff;
padding: 10px 10px;
bottom: 0;
}
.bottom_wrapper .message_input_wrapper {
display: inline-block;
height: 50px;
border-radius: 5px;
border: 1px solid #bcbdc0;
width: calc(100% - 100px);
position: relative;
padding: 0 20px;
}
.bottom_wrapper .message_input_wrapper .message_input {
border: none;
height: 100%;
box-sizing: border-box;
width: calc(100% - 40px);
position: absolute;
outline-width: 0;
color: gray;
}
.bottom_wrapper .send_message {
width: 90px;
height: 50px;
display: inline-block;
border-radius: 5px;
background-color: #563D7C;
color: #fff;
cursor: pointer;
transition: all 0.2s linear;
text-align: center;
float: right;
}
Picture:
Click here