Absolute position of a div inside a div without absolute position - html

I made a fiddle of my problem to easily see it:
https://jsfiddle.net/6jzb09nd/
I have a series of nested divs. And the very bottom of the nest i want a div absolutely positioned so I can center it inside it's parent div.
It works find when it's the only thing on the page but when I start adding other elements the positioning gets all messed up.
In the fiddle if you uncomment the "//float:left", you can see the positioning break.
Here's the code:
.col-sm-2,
.col-sm-10 {
//float:left;
}
.leftnumouter {
color: #fff;
font-size: 4.5vw;
height: 4.5vw;
width: 4.5vw;
float: left;
background: #393;
position: relative;
border: 0px solid black;
}
.rightnumouter {
color: #fff;
font-size: 4.5vw;
height: 4.5vw;
width: 4.5vw;
float: left;
background: #C33;
position: relative;
border: 0px solid black;
}
.leftnuminner {
color: #000;
position: absolute;
font-weight: bold;
font-family: Arial, Helvetica, sans-serif;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.rightnuminner {
color: #fff;
font-weight: bold;
font-family: Arial, Helvetica, sans-serif;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.lefttextouter {
background: #3C9;
border-radius: 0 1.5vw 1.5vw 0;
color: #000;
font-size: 3vw;
height: 3.2vw;
text-transform: uppercase;
float: left;
padding: 0 0 0 0;
position: relative;
}
.righttextouter {
background: #C69;
border-radius: 0 1.5vw 1.5vw 0;
color: #000;
font-size: 3vw;
height: 3.2vw;
text-transform: uppercase;
float: left;
padding: 0 0 0 .2vw;
position: relative;
}
.lefttextinner {
color: #000;
margin: 0 .5vw 0 0;
}
.righttextinner {
color: #000;
margin: 0 1vw 0 0;
}
<div class="col-sm-2"> Blah
</div>
<div class="col-sm-10">
<div class="preview">
<div class="databubble">
<div class="leftnumouter">
<div class="leftnuminner">5
</div>
</div>
<div class="lefttextouter">
<div class="lefttextinner">Sales
</div>
</div>
</div>
<div class="databubble">
<div class="rightnumouter">
<div class="rightnuminner">3
</div>
</div>
<div class="righttextouter">
<div class="righttextinner">Orders
</div>
</div>
</div>
</div>
</div>

Since an element with float collapse to its content, you need to give it a width
.col-sm-2,
.col-sm-10 {
float:left;
width: 100%;
}
.leftnumouter {
color: #fff;
font-size: 4.5vw;
height: 4.5vw;
width: 4.5vw;
float: left;
background: #393;
position: relative;
border: 0px solid black;
}
.rightnumouter {
color: #fff;
font-size: 4.5vw;
height: 4.5vw;
width: 4.5vw;
float: left;
background: #C33;
position: relative;
border: 0px solid black;
}
.leftnuminner {
color: #000;
position: absolute;
font-weight: bold;
font-family: Arial, Helvetica, sans-serif;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.rightnuminner {
color: #fff;
font-weight: bold;
font-family: Arial, Helvetica, sans-serif;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.lefttextouter {
background: #3C9;
border-radius: 0 1.5vw 1.5vw 0;
color: #000;
font-size: 3vw;
height: 3.2vw;
text-transform: uppercase;
float: left;
padding: 0 0 0 0;
position: relative;
}
.righttextouter {
background: #C69;
border-radius: 0 1.5vw 1.5vw 0;
color: #000;
font-size: 3vw;
height: 3.2vw;
text-transform: uppercase;
float: left;
padding: 0 0 0 .2vw;
position: relative;
}
.lefttextinner {
color: #000;
margin: 0 .5vw 0 0;
}
.righttextinner {
color: #000;
margin: 0 1vw 0 0;
}
<div class="col-sm-2"> Blah
</div>
<div class="col-sm-10">
<div class="preview">
<div class="databubble">
<div class="leftnumouter">
<div class="leftnuminner">5
</div>
</div>
<div class="lefttextouter">
<div class="lefttextinner">Sales
</div>
</div>
</div>
<div class="databubble">
<div class="rightnumouter">
<div class="rightnuminner">3
</div>
</div>
<div class="righttextouter">
<div class="righttextinner">Orders
</div>
</div>
</div>
</div>
</div>
Or set up a few more rules to make it all behave
.preview {
overflow: hidden;
white-space: nowrap;
}
.databubble {
display: inline-block;
}
Sample
.col-sm-2,
.col-sm-10 {
float:left;
}
.col-sm-2:after,
.col-sm-10:after {
content: '';
clear: both;
display: block;
}
/* added these 2 rules */
.preview {
overflow: hidden;
white-space: nowrap;
}
.databubble {
display: inline-block;
}
.leftnumouter {
color: #fff;
font-size: 4.5vw;
height: 4.5vw;
width: 4.5vw;
float: left;
background: #393;
position: relative;
border: 0px solid black;
}
.rightnumouter {
color: #fff;
font-size: 4.5vw;
height: 4.5vw;
width: 4.5vw;
float: left;
background: #C33;
position: relative;
border: 0px solid black;
}
.leftnuminner {
color: #000;
position: absolute;
font-weight: bold;
font-family: Arial, Helvetica, sans-serif;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.rightnuminner {
color: #fff;
font-weight: bold;
font-family: Arial, Helvetica, sans-serif;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.lefttextouter {
background: #3C9;
border-radius: 0 1.5vw 1.5vw 0;
color: #000;
font-size: 3vw;
height: 3.2vw;
text-transform: uppercase;
float: left;
padding: 0 0 0 0;
position: relative;
}
.righttextouter {
background: #C69;
border-radius: 0 1.5vw 1.5vw 0;
color: #000;
font-size: 3vw;
height: 3.2vw;
text-transform: uppercase;
float: left;
padding: 0 0 0 .2vw;
position: relative;
}
.lefttextinner {
color: #000;
margin: 0 .5vw 0 0;
}
.righttextinner {
color: #000;
margin: 0 1vw 0 0;
}
<div class="col-sm-2"> Blah
</div>
<div class="col-sm-10">
<div class="preview">
<div class="databubble">
<div class="leftnumouter">
<div class="leftnuminner">5
</div>
</div>
<div class="lefttextouter">
<div class="lefttextinner">Sales
</div>
</div>
</div>
<div class="databubble">
<div class="rightnumouter">
<div class="rightnuminner">3
</div>
</div>
<div class="righttextouter">
<div class="righttextinner">Orders
</div>
</div>
</div>
</div>
</div>

Related

Images destroy the card format

I have a grid layout of cards. When I upload photos to a product card, there are several times that the entire format of the card is damaged. That is, no labels, the name, the description of the product and some other things are not visible.
I am attaching 2 screenshots (one without and one with photos)
.bg-color {
background-color: #eee;
padding: 60px 0;
}
.containers {
width: 90%;
margin: 0 auto;
}
.title {
margin-bottom: 50px;
padding-bottom: 40px;
text-align: center;
position: relative;
}
.title::before {
content: '';
width: 200px;
height: 3px;
background-color: #dbdbdb;
position: absolute;
bottom: 15%;
left: 50%;
transform: translateX(-50%);
}
.title::after {
content: '\f005';
font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
color: #dbdbdb;
width: 50px;
height: 20px;
text-align: center;
line-height: 20px;
position: absolute;
bottom: 10%;
left: 10%;
/* background-color: #eee;
*/
transform: translateX(-50%);
font-size: 16px;
}
.title p {
color: #999;
font-style: italic;
font-weight: 700;
margin: 0;
}
.title h1 {
font-size: 44px;
color: #131313;
font-weight: 900;
text-transform: capitalize;
}
.title h1 span {
color: #fa0;
}
.my-card {
transition: all .2s ease-in-out;
border-radius: 3px;
}
.card-main {
position: relative;
}
.price {
position: absolute;
background: #fa0;
font-weight: 700;
color: #ffff;
text-align: center;
display: block;
text-transform: uppercase;
height: 30px;
width: 50px;
border-radius: 0 15px 15px 0;
line-height: 30px;
font-style: italic;
left: -9px;
top: 30px;
}
.price::after {
border-top: 6px solid #c80;
content: '';
position: absolute;
bottom: -6px;
left: 0;
border-left: 8px solid transparent;
border-right: 0px solid transparent;
}
.label {
position: absolute;
top: 10px;
/* bottom: 104px;
*/
left: -9px;
font-size: 10px;
font-weight: 400;
text-transform: uppercase;
z-index: 2;
line-height: 100%;
color: #ffff;
border-radius: 3px;
padding: 5px 8px;
}
.label-green {
background: #5cb85c;
}
.label2 {
position: absolute;
top: 10px;
/* bottom: 104px;
*/
right: -9px;
font-size: 10px;
font-weight: 400;
text-transform: uppercase;
z-index: 2;
line-height: 100%;
color: #ffff;
border-radius: 3px;
padding: 5px 8px;
}
.label-red {
background: #C5312D;
}
.image img {
width: 100%;
height: 100%;
position: center;
}
.cart-line {
height: 2px;
background: #f1f1f1;
}
.cart-item {
text-align: center;
line-height: 45px;
background: #fa0;
/* background: rgb(199, 136, 53);
*/
transition: all 0.4s ease-in-out;
position: relative;
top: -30px;
}
.cart-item ul {
padding: 0;
margin: 0;
}
.cart-item ul li {
display: inline-block;
list-style-type: none;
position: relative;
font-size: 25px;
}
.cart-item ul li::after {
content: '';
width: 1px;
height: 18px;
background: rgba(255, 255, 255, .15);
position: absolute;
left: -2px;
top: 10px;
}
.my-card:hover .cart-item {
opacity: 1;
top: 0;
}
.item-container {
position: absolute;
right: -40px;
top: 10px;
z-index: 4;
transition: 0.6s;
opacity: 0;
}
.p {
border: 1px solid rgb(233, 233, 233);
border-radius: 2px;
height: 40px;
width: 40px;
cursor: pointer;
}
.p img {
width: 100%;
height: 100%;
opacity: 0.8;
}
.p img:hover {
opacity: 1;
}
.my-card:hover .item-container {
opacity: 1;
right: 10px;
}
.content {
padding: 16px 0;
text-align: center;
}
.content mat-card-title {
font-size: 16px;
color: #555;
font-weight: 700;
text-transform: capitalize;
transition: all .3s;
}
.content mat-card-title:hover {
color: #fa0;
text-decoration: none;
}
.content p {
margin-bottom: 0;
}
.content .description {
font-size: 15px;
color: #fa0;
font-weight: 500;
font-style: italic;
margin-right: 6px;
}
<section class="bg-color">
<div class="containers">
<mat-grid-list [cols]="breakpoint" rowHeight="500px" (window:resize)="onResize($event)">
<mat-grid-tile *ngFor="let item of pagedList">
<div>
<mat-card class="my-card">
<div class="card-main">
<div *ngIf="item.buy_price != 0">
<div class="label label-green">Buy NOW</div>
<div class="price">{{item.buy_price | currency:'EUR':true}}</div>
</div>
<div *ngIf="item.seller == username">
<div class="label2 label-red">My item</div>
</div>
<!-- Small images -->
<div class="item-container">
<div *ngIf="item.images.length!==0">
<div *ngFor="let image of item.images">
<div class="p"><img [src]="'data:image/jpeg;base64,' + image.imageByte" alt="item"> </div>
</div>
</div>
</div>
<!-- 1st image -->
<div class="image">
<div *ngIf="item.images.length==0">
<img src="/assets/images/no_image_found.jpg" alt="image">
</div>
<div *ngIf="item.images.length!=0">
<img [src]="'data:image/jpeg;base64,' + item.images[0].imageByte" alt="image">
</div>
</div>
<div class="cart-line"></div>
<div class="cart-item">
<ul>
<li><a routerLink="/item-detail/{{item.id}}"><i class="bi-basket"></i></a></li>
</ul>
</div>
</div>
<div class="content">
<mat-card-title>{{item.name.length>34?item.name.substring(0,30)+ "...":item.name}}</mat-card-title>
<p><span class="description">{{item.description.length>34?item.description.substring(0,30)+ "...":item.description}}</span></p>
</div>
</mat-card>
</div>
</mat-grid-tile>
</mat-grid-list>
</div>
</section>

remove vertical space between divs

I am trying to add two images in one row and it should go on continuously in a vertical direction but the issue I am facing is I am getting space between the images vertically.
I tried to add CSS but it did not work. (note: I am looping through images so I can't apply CSS for different images, it needs to be applicable to all images at once)
.menu-spacer {
flex: 1 1 auto;
}
a {
padding-right: 5em;
}
.menu-spacer1 {
flex: 1 1 auto;
padding-top: 15em;
}
#second-row {
margin-top: 2em;
}
#first-row {
border-top-left-radius: 3em;
box-shadow: 0 16px 24px 2px rgb(245, 245, 248), 0 6px 15px 1px rgba(0, 0, 0, 0.12), 0 8px 10px -5px rgba(0, 0, 0, 0.3);
}
#search-button {
margin-left: 7em;
border-radius: 2em;
width: 24em;
height: 30px;
outline-style: none;
text-align: center;
border-width: 2px;
border-color: black;
}
#mn {
height: 12em;
}
h1 {
color: white;
margin-left: 2em;
margin-top: 3em;
font-size: 28px;
}
#img {
margin-top: 9em;
padding: 0;
width: 12em;
margin-left: 2em;
}
#img1 {
height: 13em;
padding: 0em;
}
#img2 {
float: right;
/* float: top; */
height: 13em;
position: relative;
top: -15em;
}
.example-card {
padding: 0em;
}
p {
margin-top: 10em;
margin-left: -214px;
color: #e67500;
font-size: 15px;
font-family: ProximaNova, Arial, Helvetica Neue, sans-serif;
}
h2 {
margin-top: 12em;
margin-left: -567px;
color: #e67500;
font-size: 15px;
font-family: ProximaNova, Arial, Helvetica Neue, sans-serif;
}
#rating {
font-size: 15px;
margin-top: 16em;
margin-left: -95px;
color: white;
}
mat-icon {
font-size: 15px;
position: relative;
top: 2px;
left: 5px;
}
#ratingcount {
font-size: 12px;
color: #e67500;
margin-top: 24em;
margin-left: -39px;
}
#time {
font-size: 16px;
margin-top: 15em;
margin-left: -32em;
color: white;
}
#timealias {
font-size: 12px;
margin-top: 24em;
margin-left: -5em;
color: #e67500;
}
#cost {
font-size: 16px;
color: white;
margin-top: 15em;
position: relative;
right: 32em;
}
#costalias {
position: relative;
font-size: 12px;
top: 12em;
left: -45em;
color: #e67500;
}
.mat-divider {
color: white;
background-color: yellow;
height: 43px;
position: relative;
left: -554px;
top: 132px;
}
/* #right-content{
margin-left: 74em;
margin-top: -13em;
} */
#menu-img {
margin-right: 4em;
/* margin-top: 6em; */
height: 13em;
margin-top: 0em;
/* vertical-align: bottom; */
}
#menu-name {
margin-left: 1.5em;
margin-top: 1em;
color: #282c3f;
font-size: 15px;
font-weight: 500;
font-family: Roboto, "Helvetica Neue", sans-serif;
}
#veg-img {
position: relative;
top: 115px;
right: 332px;
width: 15px;
}
#menu-type {
position: relative;
top: -10em;
left: 236px;
font-family: ProximaNova, Arial, Helvetica Neue, sans-serif;
color: #7e808c;
font-size: 13px;
}
#menu-price {
position: relative;
top: -275px;
right: -236px;
color: #535665;
font-size: 15px;
}
.menu-button {
color: green;
background-color: white;
border-color: yellowgreen;
position: relative;
top: -319px;
left: 194px;
width: 5em;
height: 2em;
border-style: solid;
}
<app-swiggy-header></app-swiggy-header>
<div class="row-6" id="second-row">
<mat-toolbar [ngStyle]="{'backgroundColor': '#171a29'}" id="mn">
<mat-toolbar-row>
<img src="assets/swiggyimages/moriz.jpg" id="img">
<h1>Moriz Restaurant</h1>
<p>Fast Food, Snacks, Pastas, Salads, Beverages, Home Food, Italian, North Indian, Ma</p>
<h2>ACES Layout</h2>
<span id="rating">
<mat-icon>star</mat-icon>4.5
</span>
<span id="ratingcount">100+ Ratings</span>
<hr>
<mat-divider vertical></mat-divider>
<span id="time">30 mins</span>
<span id="timealias">Delivery Time</span>
<hr>
<mat-divider vertical></mat-divider>
<span id="cost">150</span>
<span id="costalias">Cost for two</span>
</mat-toolbar-row>
</mat-toolbar>
</div>
<div class="row">
<div class="col-3" id="left-content">abc</div>
<div class="col-xs-12 col-md-8">
<div class="row">
<div class="col-xs-4 ">
<img src="assets/swiggyimages/moriz.jpg" class="img-responsive" alt="Logo" id="menu-img">
<img src="assets/swiggyimages/veg.png" id="veg-img">
<p id="menu-name">Paneer-Veg-Biryani</p>
<p id="menu-type">Rice</p>
<p id="menu-price">105</p>
<button class="menu-button">ADD</button>
</div>
<div class="col-xs-4 ">
<img src="assets/swiggyimages/moriz.jpg" class="img-responsive" alt="Logo" id="menu-img">
<img src="assets/swiggyimages/veg.png" id="veg-img">
<p id="menu-name">Paneer-Biryani</p>
<p id="menu-type">veg</p>
<p id="menu-price">105</p>
<button class="menu-button">ADD</button>
</div>
<div class="col-xs-4 ">
<img src="assets/swiggyimages/moriz.jpg" class="img-responsive" alt="Logo" id="menu-img">
<img src="assets/swiggyimages/veg.png" id="veg-img">
<p id="menu-name">Paneer-Biryani</p>
<p id="menu-type">veg</p>
<p id="menu-price">105</p>
<button class="menu-button">ADD</button>
</div>
<div class="col-xs-4 ">
<img src="assets/swiggyimages/moriz.jpg" class="img-responsive" alt="Logo" id="menu-img">
<img src="assets/swiggyimages/veg.png" id="veg-img">
<p id="menu-name">Paneer-Biryani</p <p id="menu-type">veg</p>
<p id="menu-price">105</p>
<button class="menu-button">ADD</button>
</div>
</div>
</div>
<div class="col-3" id="right-content">mnc</div>
</div>

How to control CSS arrow size

I created an arrow in CSS. Everything is working as it should except the size of the arrow. I am not sure how I can make it smaller.
How can I make the arrow smaller?
#blue {
width: 100%;
height: 100vh;
background: blue;
}
#box2 {
position: absolute;
top: 25%;
right: 25%;
z-index: 1;
}
#box2Text {
color: #FFF;
font-family: 'Muli', sans-serif;
font-size: 2rem;
font-weight: 300;
line-height: 1.4em;
padding: 80px;
border: 6px solid #FFF;
border-radius: 2px;
display: block;
text-align: center;
}
#arrow {
margin-top: 10px;
border: solid #FFF;
border-width: 0 3px 3px 0;
display: block;
padding: 3px;
transform: rotate(45deg);
-webkit-transform: rotate(45deg);
}
<section id="blue">
<div id="box2">
<span id="box2Text">View Services</span>
<div id="arrow"></div>
</div>
</section>
Desired output:
Use the arrow as a pseudo element of the text div and you can easily place it and adjust its size:
#blue {
width: 100%;
height: 100vh;
background: blue;
}
#box2 {
position: absolute;
top: 25%;
right: 25%;
z-index: 1;
}
#box2Text {
color: #FFF;
font-family: 'Muli', sans-serif;
font-size: 2rem;
font-weight: 300;
line-height: 1.4em;
padding: 80px;
border: 6px solid #FFF;
border-radius: 2px;
display: block;
text-align: center;
position:relative;
}
#box2Text:after {
content:"";
left:calc(50% - 5px);
margin-top:40px;
position:absolute;
border: solid #FFF;
border-width: 0 3px 3px 0;
width:10px;
height:10px;
transform: rotate(45deg);
}
<section id="blue">
<div id="box2">
<span id="box2Text">View Services</span>
</div>
</section>
You just need to specify CSS width and height attributes to #arrow. you might need to adjust the arrow position after that according to your needs
#blue {
width: 100%;
height: 100vh;
background: blue;
}
#box2 {
position: absolute;
top: 25%;
right: 25%;
z-index: 1;
}
#box2Text {
color: #FFF;
font-family: 'Muli', sans-serif;
font-size: 2rem;
font-weight: 300;
line-height: 1.4em;
padding: 80px;
border: 6px solid #FFF;
border-radius: 2px;
display: block;
text-align: center;
}
#arrow {
margin-top: 10px;
border: solid #FFF;
border-width: 0 3px 3px 0;
display: block;
padding: 3px;
transform: rotate(45deg);
-webkit-transform: rotate(45deg);
width: 5px;
height: 5px;
}
<section id="blue">
<div id="box2">
<span id="box2Text">View Services</span>
<div id="arrow"></div>
</div>
</section>
Like this?
#blue {
width: 100%;
height: 100vh;
background: blue;
}
#box2 {
position: absolute;
top: 25%;
right: 25%;
z-index: 1;
}
#box2Text {
color: #FFF;
font-family: 'Muli', sans-serif;
font-size: 2rem;
font-weight: 300;
line-height: 1.4em;
padding: 80px;
border: 6px solid #FFF;
border-radius: 2px;
display: block;
text-align: center;
}
#arrow {
margin-right:15px;
margin-bottom:5px;
border: solid #FFF;
border-width: 0 3px 3px 0;
display: inline-block;
padding: 3px;
transform: rotate(-45deg);
-webkit-transform: rotate(-45deg);
width: 5px;
height: 5px;
}
<section id="blue">
<div id="box2">
<span id="box2Text"><div id="arrow"></div><span>View Services</span></span>
</div>
</section>

How to add more than one circles to this same progress bar using HTML and CSS?

I am trying to create a progress bar with multiple money til current date based on this UX sample
So far, I am able to display the first circle. Here's an output output of my code:
HTML:
<div class={`col-md-12`}>
<h3 class="line-bottom mt-0">Money Earned to Date</h3>
<div class="row">
<div class="col-md-6">
<div class="progress">
<div class="progress-bar" style="width: 12%; background: #ed687c;">
<span class="progress-icon fa fa-dollar-sign" style="color: #707070; border-color: #707070;"></span>
<div class="progress-value">$100</div>
</div>
</div>
</div>
</div>
</div>
CSS
.progressbar-title {
font-size: 14px;
color: #848484;
text-transform: capitalize;
}
.progress {
height: 30px;
overflow: visible;
background: #f4bc25;
margin-top: 25px;
margin-bottom: 40px;
border-radius: 20px;
border: 1px solid #707070;
}
.progress .progress-bar {
position: relative;
}
.progress .progress-icon {
width: 55px;
height: 53px;
line-height: 47px;
border-radius: 50%;
font-size: 20px;
position: absolute;
top: -14px;
right: 0;
padding: 0 19px;
background: #fff;
border-width: 3px;
border-style: solid;
color: #707070;
}
.progress-value {
font-size: 15px;
color: #000;
position: absolute;
top: 45px;
right: 11px;
}
Can someone please help me finish the remaining parts on the UX?
if you want to make more circles dynamically you have to make it with Javacript but if you want it static (with only 5 circles) then here you go :
.row,.progress{ position: relative;width: 100%;}
.progress-bar{position:relative;background: #f6ba2b;height: 24px; border-radius:36px}
.progress-bar > .offCircle{
position:absolute;width:100%;
height:100%;
/* background:red; */
}
.progress:after,
.progress-bar:before,
.progress-bar:after,
.progress-bar > .offCircle:before,
.progress-bar > .offCircle:after
{
position:absolute;
color: #707070;
top: 0;
width:33px;
height: 33px;
background:#fff;
margin-top: -7.5px;
margin-top: -6.5px;
border-radius:36px;
border: 2px solid #707070;
text-shadow: 0 0 0px black;
line-height: 2.2;
text-align: center;
}
.progress-bar > .offCircle:before{
content: '$\A 100';
left:1.67%;
}
.progress-bar > .offCircle:after{
content: '$\A 500';
left:8.33%;
}
.progress-bar:before{
content: '$$\A 1000';
left:16.67%;
}
.progress-bar:after{
content: '$$\A 2500';
left:41.76%;
}
.progress:after{
content: '$$\A 5000';
left:83.33%;
}
<div class="row">
<div class="col-md-6">
<div class="progress">
<div class="progress-bar">
<span class="offCircle"></span>
<div class="progress-value fa fa-dollar-sign"></div>
</div>
</div>
</div>
</div>
to make it animate add css transition for the effect, you have to calculate specific value as % and pass it to a Progress-bar with javascript, you can do it in many ways.
I was finally able to complete the rest of the parts on my own.
See screenshot
In case if anyone is interested, here's the complete code:
HTML:
<div class="col-md-12">
<h3 class="heading">Money Earned to Date</h3>
<div class="row">
<div class="col-md-10">
<div class="checkout-wrap">
<ul class="checkout-bar">
<li class="visited first">
$100
</li>
<li class="previous first">$500</li>
<li class="active">
$1,000
<div class="progress-bar" style="width: 85%; background: #cc504c;"></div>
<div class="progress-value">$1,500</div>
</li>
<li class="next">$2,500</li>
<li>$5,000</li>
</ul>
<h2 class="currentMoney">$1,500.00</h2>
</div>
</div>
</div>
</div>
CSS
#-webkit-keyframes myanimation {
from {
left: 0%;
}
to {
left: 50%;
}
}
h1 {
text-align: center;
font-family: "PT Sans Caption", sans-serif;
font-weight: 400;
font-size: 30px;
padding: 20px 0;
color: #777;
}
.checkout-wrap {
color: #444;
font-family: "PT Sans Caption", sans-serif;
margin: 40px auto;
max-width: 1200px;
position: relative;
}
ul.checkout-bar {
margin: 0 20px;
}
ul.checkout-bar li {
color: #444;
display: block;
font-size: 16px;
font-weight: 600;
padding: 14px 20px 14px 80px;
position: relative;
}
ul.checkout-bar li:before {
background: #fff;
border: 2px solid #707070;
border-radius: 50%;
color: #707070;
font-size: 20px;
font-weight: 700;
left: 20px;
line-height: 37px;
height: 35px;
position: absolute;
text-align: center;
text-shadow: 1px 1px rgba(0, 0, 0, 0.2);
top: 4px;
width: 35px;
z-index: 2;
}
ul.checkout-bar li.active {
color: #444;
font-weight: bold;
padding-left: 10px;
letter-spacing: 1px;
}
ul.checkout-bar li.active:before {
background: #fff;
z-index: 3;
border-color: #707070;
color: #707070;
}
ul.checkout-bar li.visited {
background: #ECECEC;
color: #444;
z-index: 3;
padding-left: 10px;
letter-spacing: 1px;
}
ul.checkout-bar li.visited:before {
background: #fff;
z-index: 3;
border-color: #707070;
color: #707070;
}
ul.checkout-bar li:nth-child(1):before {
content: "$";
}
ul.checkout-bar li:nth-child(2):before {
content: "$";
}
ul.checkout-bar li:nth-child(3):before {
content: "$$";
}
ul.checkout-bar li:nth-child(4):before {
content: "$$";
}
ul.checkout-bar li:nth-child(5):before {
content: "$$";
}
ul.checkout-bar a {
color: #444;
font-size: 16px;
font-weight: 600;
text-decoration: none;
padding-left: 10px;
letter-spacing: 1px;
}
ul.checkout-bar li.active .progress-value{
width: 50px;
height: 25px;
font-size: 16px;
font-weight: 600;
color: #f4bc25;
line-height: 25px;
border-radius: 4px;
position: absolute;
top: -113px;
right: -23px;
letter-spacing: 1px;
}
ul.checkout-bar li.active .t_progress-bar:after{
content: "\F3C5";
font-family: "Font Awesome 5 Free";
font-weight: 900;
position: absolute;
top: -88px;
right: -10px;
font-size: 25px;
font-weight: 700;
color: #f4bc25;
}
.finances .checkout-wrap .currentMoney {
text-align: right;
padding-top: 100px;
font-size: 35px;
color: #f4bc25;
letter-spacing: 1px;
}
#media all and (min-width: 800px) {
.checkout-bar li.active:after {
-webkit-animation: myanimation 3s 0;
background-size: 35px 35px;
background-color: #f4bc25;
content: "";
height: 28px;
width: 50%;
left: 50%;
position: absolute;
top: -50px;
z-index: 0;
}
.checkout-wrap {
margin: 80px auto 0 auto
}
ul.checkout-bar {
background-size: 35px 35px;
background-color: #fff;
border-radius: 15px;
height: 30px;
margin: 0 auto;
padding: 0;
position: absolute;
width: 100%;
border: 1px solid #000;
}
ul.checkout-bar:before {
background-size: 35px 35px;
background-color: #f4bc25;
border-radius: 15px;
content: " ";
height: 28px;
left: 0;
position: absolute;
width: 10%;
}
ul.checkout-bar li {
display: inline-block;
margin: 50px 0 0;
padding: 0 0 0 20px;
text-align: center;
width: 17%;
}
ul.checkout-bar li:before {
height: 55px;
width: 55px;
left: 40%;
line-height: 55px;
position: absolute;
top: -65px;
z-index: 1;
}
ul.checkout-bar li.visited {
background: none;
}
ul.checkout-bar li.visited:after {
background-size: 35px 35px;
background-color: #f4bc25;
content: "";
height: 28px;
left: 50%;
position: absolute;
top: -50px;
width: 100%;
z-index: 1;
}
}

CSS Animate issue

Ever since I added "position absoulte" to my div ".container" in my code below, my CSS animate code zooms in from the bottom then hiccups and positions itself to the center.
How can I make my animate zoom just zoom in right to the center without this hiccup where it goes down first then a second later it automatically moves to the center?
If I remove the position absolute from the .container div the animate zoom works just fine but it's not centered anymore vertically (just horizontally). The reason I used position absolute and left 0 and right 0 was to center it both ways.
Here is my code:
* {
box-sizing: border-box;
}
html,
body {
height: 100%;
margin: 0 auto;
color: white;
text-align: center;
font-family: 'Lato', serif;
background: linear-gradient(white 70px, #007580 70px);
-webkit-text-size-adjust: none;
}
header,
footer {
background: #007580
}
body,
main {
display: flex;
flex: 1;
}
body {
flex-flow: column;
}
header {
min-height: 35px;
}
footer {
min-height: 35px;
}
section {
margin: auto;
width: 95%;
height: 100%;
color: black;
background-color: white;
}
.categories {
position: relative;
top: 3px;
color: white;
font-size: 16px;
font-weight: 300;
word-spacing: 26px;
padding-bottom: 2px;
}
.categories a {
text-decoration: none;
color: inherit;
}
.legal {
position: absolute;
bottom: 0;
width: 100%;
height: 30px;
font-weight: 300;
word-spacing: 15px;
}
.legal a {
text-decoration: none;
font-size: 14px;
color: white;
}
.quote {
position: relative;
margin: auto;
font-size: 20px;
font-weight: 300;
bottom: 80px;
height: 0;
}
.searchcontainer {
position: relative;
height: 0;
bottom: 43px;
margin: auto;
width: 380px;
;
}
input[type=text] {
width: 100%;
display: inline-block;
border: 2px solid #ddd;
border-radius: 4px;
padding: 6px 0 7px 40px;
background-image: url('https://image.ibb.co/j9esac/searchicon.png');
background-position: 10px 6px;
background-repeat: no-repeat;
font-size: 16px;
background-color: white;
}
.innercircle {
height: 89px;
width: 89px;
border-radius: 50%;
background-color: white;
margin: auto;
position: relative;
bottom: 93px;
}
.outercircle {
height: 120px;
width: 120px;
border-radius: 50%;
background-color: #007580;
margin: auto;
position: relative;
top: 11px;
}
.D {
font-size: 100px;
font-weight: 100;
position: relative;
bottom: 196px;
right: 3px;
margin: auto;
color: #007580;
height: 0;
font-family: 'Amiri', serif;
letter-spacing: -10px;
}
.D a {
text-decoration: none;
color: inherit;
}
.R {
font-size: 55px;
font-weight: 100;
position: relative;
bottom: 173px;
right: 2px;
margin: auto;
color: #007580;
height: 0;
font-family: 'Amiri', serif;
letter-spacing: -10px;
}
.R a {
text-decoration: none;
color: inherit;
}
.ICONwhatsnew {
position: relative;
margin: auto;
bottom: 194px;
right: 191px;
width: 0;
display: block;
height: 0;
}
.ICONwhatsnew a {
text-decoration: none;
color: inherit;
}
.ICONworldlanguages {
position: relative;
margin: auto;
bottom: 190px;
right: 116px;
width: 0;
display: block;
height: 0;
}
.ICONworldlanguages a {
text-decoration: none;
color: inherit;
}
.ICONsignin {
position: relative;
margin: auto;
bottom: 192px;
left: 83px;
width: 0;
display: block;
height: 0;
}
.ICONsignin a {
text-decoration: none;
color: inherit;
}
.ICONcart {
position: relative;
margin: auto;
bottom: 192px;
left: 149px;
width: 0;
display: block;
height: 0;
}
.ICONcart a {
text-decoration: none;
color: inherit;
}
.container {
font-size: 17px;
font-weight: 400;
color: #007580;
top: 50%;
left: 0;
right: 0;
position: absolute;
}
input[type=unams] {
width: 80%;
padding: 12px 45px;
margin: 22px 0 0 0;
border: 1px solid #007580;
box-sizing: border-box;
border-radius: 0px;
-webkit-appearance: none;
font-size: 17px;
background-image: url('https://image.ibb.co/fZHHnc/signin.png');
background-position: 10px 8px;
background-repeat: no-repeat;
background-size: 25px;
}
input[type=password] {
width: 80%;
padding: 12px 45px;
/* first is how big you want the input box 2nd is positioning of word password */
margin: 22px 0 15px 0;
border: 1px solid #007580;
box-sizing: border-box;
border-radius: 0px;
-webkit-appearance: none;
font-size: 17px;
background-image: url('https://image.ibb.co/jC7gfx/lock.png');
background-position: 10px 8px;
background-repeat: no-repeat;
background-size: 25px;
}
.buttonlg {
background-color: #007580;
border: none;
color: white;
width: 25%;
font-size: 17px;
height: 38px;
margin: auto;
text-align: center;
}
.outerform {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.innerform {
width: 90%;
height: 90%;
}
.box {
background-color: white;
border: 1px solid #007580;
height: 100%;
}
.animate {
-webkit-animation: animatezoom 0.6s;
animation: animatezoom 0.6s
}
#-webkit-keyframes animatezoom {
from {
-webkit-transform: scale(0)
}
to {
-webkit-transform: scale(1)
}
}
::-webkit-input-placeholder {
/* WebKit browsers */
color: lightgrey;
opacity: 1 !important;
}
.circlelogo1 {
background: #007580;
border-radius: 50%;
height: 30px;
width: 30px;
position: relative;
margin: auto;
/*
Child elements with absolute positioning will be
positioned relative to this div
*/
}
.circlelogo2 {
position: absolute;
background: white;
border-radius: 50%;
height: 18px;
width: 18px;
/*
Put top edge and left edge in the center
*/
top: 50%;
left: 50%;
margin: -9px 0px 0px -9px;
/*
Offset the position correctly with
minus half of the width and minus half of the height
*/
}
<div class="outercircle"></div>
<div class="innercircle"></div>
<div class="D">
D
</div>
<div class="R">
R
</div>
<div class="quote">
You will always be your greatest investment.
</div>
<div class="searchcontainer">
<form>
<input name="search" placeholder="Search all resources..." type="text">
</form>
</div>
<div class="ICONsignin">
<img height="37px" src="https://svgshare.com/i/5SR.svg">
</div>
<div class="ICONcart">
<img height="39px" src="https://svgshare.com/i/5SE.svg">
</div>
<div class="ICONworldlanguages">
<img height="34px" src="https://svgshare.com/i/5XW.svg">
</div>
<div class="ICONwhatsnew">
<img height="43px" src="https://svgshare.com/i/5aX.svg">
</div>
<header>
<div class="categories">
<b>Categories</b> Newest Popular Music Youth
</div>
</header>
<main>
<section>
<div class="outerform">
<div class="innerform">
<form class="animate box">
<div class="container">
<div class="circlelogo1">
<div class="circlelogo2">
</div>
</div>
<input type="unams" placeholder="Username" name="uname" required>
<input type="password" placeholder="Password" name="psw" required><br>
<button class="buttonlg" type="submit">Log In</button>
</div>
</form>
</div>
</div>
</section>
</main>
<footer>
<div class="legal">
Contact Privacy Terms Copyright About
</div>
</footer>
You are using position:absolute and the parent element is not set with relative so the form is not relative to the scaled container which is creating this issue. You need to set position:relative to the parent container and then adjust the centering:
.box {
...
position:relative; /*Added this*/
}
.container {
...
transform:translate(0,-50%); /*Added this*/
top: 50%;
...
}
Here is the full code:
* {
box-sizing: border-box;
}
html,
body {
height: 100%;
margin: 0 auto;
color: white;
text-align: center;
font-family: 'Lato', serif;
background: linear-gradient(white 70px, #007580 70px);
-webkit-text-size-adjust: none;
}
header,
footer {
background: #007580
}
body,
main {
display: flex;
flex: 1;
}
body {
flex-flow: column;
}
header {
min-height: 35px;
}
footer {
min-height: 35px;
}
section {
margin: auto;
width: 95%;
height: 100%;
color: black;
background-color: white;
}
.categories {
position: relative;
top: 3px;
color: white;
font-size: 16px;
font-weight: 300;
word-spacing: 26px;
padding-bottom: 2px;
}
.categories a {
text-decoration: none;
color: inherit;
}
.legal {
position: absolute;
bottom: 0;
width: 100%;
height: 30px;
font-weight: 300;
word-spacing: 15px;
}
.legal a {
text-decoration: none;
font-size: 14px;
color: white;
}
.quote {
position: relative;
margin: auto;
font-size: 20px;
font-weight: 300;
bottom: 80px;
height: 0;
}
.searchcontainer {
position: relative;
height: 0;
bottom: 43px;
margin: auto;
width: 380px;
;
}
input[type=text] {
width: 100%;
display: inline-block;
border: 2px solid #ddd;
border-radius: 4px;
padding: 6px 0 7px 40px;
background-image: url('https://image.ibb.co/j9esac/searchicon.png');
background-position: 10px 6px;
background-repeat: no-repeat;
font-size: 16px;
background-color: white;
}
.innercircle {
height: 89px;
width: 89px;
border-radius: 50%;
background-color: white;
margin: auto;
position: relative;
bottom: 93px;
}
.outercircle {
height: 120px;
width: 120px;
border-radius: 50%;
background-color: #007580;
margin: auto;
position: relative;
top: 11px;
}
.D {
font-size: 100px;
font-weight: 100;
position: relative;
bottom: 196px;
right: 3px;
margin: auto;
color: #007580;
height: 0;
font-family: 'Amiri', serif;
letter-spacing: -10px;
}
.D a {
text-decoration: none;
color: inherit;
}
.R {
font-size: 55px;
font-weight: 100;
position: relative;
bottom: 173px;
right: 2px;
margin: auto;
color: #007580;
height: 0;
font-family: 'Amiri', serif;
letter-spacing: -10px;
}
.R a {
text-decoration: none;
color: inherit;
}
.ICONwhatsnew {
position: relative;
margin: auto;
bottom: 194px;
right: 191px;
width: 0;
display: block;
height: 0;
}
.ICONwhatsnew a {
text-decoration: none;
color: inherit;
}
.ICONworldlanguages {
position: relative;
margin: auto;
bottom: 190px;
right: 116px;
width: 0;
display: block;
height: 0;
}
.ICONworldlanguages a {
text-decoration: none;
color: inherit;
}
.ICONsignin {
position: relative;
margin: auto;
bottom: 192px;
left: 83px;
width: 0;
display: block;
height: 0;
}
.ICONsignin a {
text-decoration: none;
color: inherit;
}
.ICONcart {
position: relative;
margin: auto;
bottom: 192px;
left: 149px;
width: 0;
display: block;
height: 0;
}
.ICONcart a {
text-decoration: none;
color: inherit;
}
.container {
font-size: 17px;
font-weight: 400;
color: #007580;
transform:translate(0,-50%);
top: 50%;
left: 0;
right: 0;
position: absolute;
}
input[type=unams] {
width: 80%;
padding: 12px 45px;
margin: 22px 0 0 0;
border: 1px solid #007580;
box-sizing: border-box;
border-radius: 0px;
-webkit-appearance: none;
font-size: 17px;
background-image: url('https://image.ibb.co/fZHHnc/signin.png');
background-position: 10px 8px;
background-repeat: no-repeat;
background-size: 25px;
}
input[type=password] {
width: 80%;
padding: 12px 45px;
/* first is how big you want the input box 2nd is positioning of word password */
margin: 22px 0 15px 0;
border: 1px solid #007580;
box-sizing: border-box;
border-radius: 0px;
-webkit-appearance: none;
font-size: 17px;
background-image: url('https://image.ibb.co/jC7gfx/lock.png');
background-position: 10px 8px;
background-repeat: no-repeat;
background-size: 25px;
}
.buttonlg {
background-color: #007580;
border: none;
color: white;
width: 25%;
font-size: 17px;
height: 38px;
margin: auto;
text-align: center;
}
.outerform {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.innerform {
width: 90%;
height: 90%;
}
.box {
background-color: white;
border: 1px solid #007580;
height: 100%;
position:relative;
}
.animate {
-webkit-animation: animatezoom 0.6s;
animation: animatezoom 0.6s
}
#-webkit-keyframes animatezoom {
from {
-webkit-transform: scale(0)
}
to {
-webkit-transform: scale(1)
}
}
::-webkit-input-placeholder {
/* WebKit browsers */
color: lightgrey;
opacity: 1 !important;
}
.circlelogo1 {
background: #007580;
border-radius: 50%;
height: 30px;
width: 30px;
position: relative;
margin: auto;
/*
Child elements with absolute positioning will be
positioned relative to this div
*/
}
.circlelogo2 {
position: absolute;
background: white;
border-radius: 50%;
height: 18px;
width: 18px;
/*
Put top edge and left edge in the center
*/
top: 50%;
left: 50%;
margin: -9px 0px 0px -9px;
/*
Offset the position correctly with
minus half of the width and minus half of the height
*/
}
<div class="outercircle"></div>
<div class="innercircle"></div>
<div class="D">
D
</div>
<div class="R">
R
</div>
<div class="quote">
You will always be your greatest investment.
</div>
<div class="searchcontainer">
<form>
<input name="search" placeholder="Search all resources..." type="text">
</form>
</div>
<div class="ICONsignin">
<img height="37px" src="https://svgshare.com/i/5SR.svg">
</div>
<div class="ICONcart">
<img height="39px" src="https://svgshare.com/i/5SE.svg">
</div>
<div class="ICONworldlanguages">
<img height="34px" src="https://svgshare.com/i/5XW.svg">
</div>
<div class="ICONwhatsnew">
<img height="43px" src="https://svgshare.com/i/5aX.svg">
</div>
<header>
<div class="categories">
<b>Categories</b> Newest Popular Music Youth
</div>
</header>
<main>
<section>
<div class="outerform">
<div class="innerform">
<form class="animate box">
<div class="container">
<div class="circlelogo1">
<div class="circlelogo2">
</div>
</div>
<input type="unams" placeholder="Username" name="uname" required>
<input type="password" placeholder="Password" name="psw" required><br>
<button class="buttonlg" type="submit">Log In</button>
</div>
</form>
</div>
</div>
</section>
</main>
<footer>
<div class="legal">
Contact Privacy Terms Copyright About
</div>
</footer>
By the way it's better to consider another way than positioned element to center. You can do it with flex since you are already using it:
.box {
....
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
Then remove everything related to positionning from .container.
Here is the full code:
* {
box-sizing: border-box;
}
html,
body {
height: 100%;
margin: 0 auto;
color: white;
text-align: center;
font-family: 'Lato', serif;
background: linear-gradient(white 70px, #007580 70px);
-webkit-text-size-adjust: none;
}
header,
footer {
background: #007580
}
body,
main {
display: flex;
flex: 1;
}
body {
flex-flow: column;
}
header {
min-height: 35px;
}
footer {
min-height: 35px;
}
section {
margin: auto;
width: 95%;
height: 100%;
color: black;
background-color: white;
}
.categories {
position: relative;
top: 3px;
color: white;
font-size: 16px;
font-weight: 300;
word-spacing: 26px;
padding-bottom: 2px;
}
.categories a {
text-decoration: none;
color: inherit;
}
.legal {
position: absolute;
bottom: 0;
width: 100%;
height: 30px;
font-weight: 300;
word-spacing: 15px;
}
.legal a {
text-decoration: none;
font-size: 14px;
color: white;
}
.quote {
position: relative;
margin: auto;
font-size: 20px;
font-weight: 300;
bottom: 80px;
height: 0;
}
.searchcontainer {
position: relative;
height: 0;
bottom: 43px;
margin: auto;
width: 380px;
;
}
input[type=text] {
width: 100%;
display: inline-block;
border: 2px solid #ddd;
border-radius: 4px;
padding: 6px 0 7px 40px;
background-image: url('https://image.ibb.co/j9esac/searchicon.png');
background-position: 10px 6px;
background-repeat: no-repeat;
font-size: 16px;
background-color: white;
}
.innercircle {
height: 89px;
width: 89px;
border-radius: 50%;
background-color: white;
margin: auto;
position: relative;
bottom: 93px;
}
.outercircle {
height: 120px;
width: 120px;
border-radius: 50%;
background-color: #007580;
margin: auto;
position: relative;
top: 11px;
}
.D {
font-size: 100px;
font-weight: 100;
position: relative;
bottom: 196px;
right: 3px;
margin: auto;
color: #007580;
height: 0;
font-family: 'Amiri', serif;
letter-spacing: -10px;
}
.D a {
text-decoration: none;
color: inherit;
}
.R {
font-size: 55px;
font-weight: 100;
position: relative;
bottom: 173px;
right: 2px;
margin: auto;
color: #007580;
height: 0;
font-family: 'Amiri', serif;
letter-spacing: -10px;
}
.R a {
text-decoration: none;
color: inherit;
}
.ICONwhatsnew {
position: relative;
margin: auto;
bottom: 194px;
right: 191px;
width: 0;
display: block;
height: 0;
}
.ICONwhatsnew a {
text-decoration: none;
color: inherit;
}
.ICONworldlanguages {
position: relative;
margin: auto;
bottom: 190px;
right: 116px;
width: 0;
display: block;
height: 0;
}
.ICONworldlanguages a {
text-decoration: none;
color: inherit;
}
.ICONsignin {
position: relative;
margin: auto;
bottom: 192px;
left: 83px;
width: 0;
display: block;
height: 0;
}
.ICONsignin a {
text-decoration: none;
color: inherit;
}
.ICONcart {
position: relative;
margin: auto;
bottom: 192px;
left: 149px;
width: 0;
display: block;
height: 0;
}
.ICONcart a {
text-decoration: none;
color: inherit;
}
.container {
font-size: 17px;
font-weight: 400;
color: #007580;
}
input[type=unams] {
width: 80%;
padding: 12px 45px;
margin: 22px 0 0 0;
border: 1px solid #007580;
box-sizing: border-box;
border-radius: 0px;
-webkit-appearance: none;
font-size: 17px;
background-image: url('https://image.ibb.co/fZHHnc/signin.png');
background-position: 10px 8px;
background-repeat: no-repeat;
background-size: 25px;
}
input[type=password] {
width: 80%;
padding: 12px 45px;
/* first is how big you want the input box 2nd is positioning of word password */
margin: 22px 0 15px 0;
border: 1px solid #007580;
box-sizing: border-box;
border-radius: 0px;
-webkit-appearance: none;
font-size: 17px;
background-image: url('https://image.ibb.co/jC7gfx/lock.png');
background-position: 10px 8px;
background-repeat: no-repeat;
background-size: 25px;
}
.buttonlg {
background-color: #007580;
border: none;
color: white;
width: 25%;
font-size: 17px;
height: 38px;
margin: auto;
text-align: center;
}
.outerform {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.innerform {
width: 90%;
height: 90%;
}
.box {
background-color: white;
border: 1px solid #007580;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.animate {
-webkit-animation: animatezoom 0.6s;
animation: animatezoom 0.6s
}
#-webkit-keyframes animatezoom {
from {
-webkit-transform: scale(0)
}
to {
-webkit-transform: scale(1)
}
}
::-webkit-input-placeholder {
/* WebKit browsers */
color: lightgrey;
opacity: 1 !important;
}
.circlelogo1 {
background: #007580;
border-radius: 50%;
height: 30px;
width: 30px;
position: relative;
margin: auto;
/*
Child elements with absolute positioning will be
positioned relative to this div
*/
}
.circlelogo2 {
position: absolute;
background: white;
border-radius: 50%;
height: 18px;
width: 18px;
/*
Put top edge and left edge in the center
*/
top: 50%;
left: 50%;
margin: -9px 0px 0px -9px;
/*
Offset the position correctly with
minus half of the width and minus half of the height
*/
}
<div class="outercircle"></div>
<div class="innercircle"></div>
<div class="D">
D
</div>
<div class="R">
R
</div>
<div class="quote">
You will always be your greatest investment.
</div>
<div class="searchcontainer">
<form>
<input name="search" placeholder="Search all resources..." type="text">
</form>
</div>
<div class="ICONsignin">
<img height="37px" src="https://svgshare.com/i/5SR.svg">
</div>
<div class="ICONcart">
<img height="39px" src="https://svgshare.com/i/5SE.svg">
</div>
<div class="ICONworldlanguages">
<img height="34px" src="https://svgshare.com/i/5XW.svg">
</div>
<div class="ICONwhatsnew">
<img height="43px" src="https://svgshare.com/i/5aX.svg">
</div>
<header>
<div class="categories">
<b>Categories</b> Newest Popular Music Youth
</div>
</header>
<main>
<section>
<div class="outerform">
<div class="innerform">
<form class="animate box">
<div class="container">
<div class="circlelogo1">
<div class="circlelogo2">
</div>
</div>
<input type="unams" placeholder="Username" name="uname" required>
<input type="password" placeholder="Password" name="psw" required><br>
<button class="buttonlg" type="submit">Log In</button>
</div>
</form>
</div>
</div>
</section>
</main>
<footer>
<div class="legal">
Contact Privacy Terms Copyright About
</div>
</footer>
There's a few issues. In your .box styling you should add position: relative; this will force .container's absolute positioning to respect its parent, in this case .box's positioning and size. The second is the top: 50%; on .container. In certain scenarios that can seem to center the item but in others it does not. What you can do to center .container within .box is add transform: translate(0, -50%); which offsets top: 50% and centers the element. Same can be done horizontally with left: 50% and transform: translate(-50%, -50%);.
* {
box-sizing: border-box;
}
html,
body {
height: 100%;
margin: 0 auto;
color: white;
text-align: center;
font-family: 'Lato', serif;
background: linear-gradient(white 70px, #007580 70px);
-webkit-text-size-adjust: none;
}
header,
footer {
background: #007580
}
body,
main {
display: flex;
flex: 1;
}
body {
flex-flow: column;
}
header {
min-height: 35px;
}
footer {
min-height: 35px;
}
section {
margin: auto;
width: 95%;
height: 100%;
color: black;
background-color: white;
}
.categories {
position: relative;
top: 3px;
color: white;
font-size: 16px;
font-weight: 300;
word-spacing: 26px;
padding-bottom: 2px;
}
.categories a {
text-decoration: none;
color: inherit;
}
.legal {
position: absolute;
bottom: 0;
width: 100%;
height: 30px;
font-weight: 300;
word-spacing: 15px;
}
.legal a {
text-decoration: none;
font-size: 14px;
color: white;
}
.quote {
position: relative;
margin: auto;
font-size: 20px;
font-weight: 300;
bottom: 80px;
height: 0;
}
.searchcontainer {
position: relative;
height: 0;
bottom: 43px;
margin: auto;
width: 380px;
;
}
input[type=text] {
width: 100%;
display: inline-block;
border: 2px solid #ddd;
border-radius: 4px;
padding: 6px 0 7px 40px;
background-image: url('https://image.ibb.co/j9esac/searchicon.png');
background-position: 10px 6px;
background-repeat: no-repeat;
font-size: 16px;
background-color: white;
}
.innercircle {
height: 89px;
width: 89px;
border-radius: 50%;
background-color: white;
margin: auto;
position: relative;
bottom: 93px;
}
.outercircle {
height: 120px;
width: 120px;
border-radius: 50%;
background-color: #007580;
margin: auto;
position: relative;
top: 11px;
}
.D {
font-size: 100px;
font-weight: 100;
position: relative;
bottom: 196px;
right: 3px;
margin: auto;
color: #007580;
height: 0;
font-family: 'Amiri', serif;
letter-spacing: -10px;
}
.D a {
text-decoration: none;
color: inherit;
}
.R {
font-size: 55px;
font-weight: 100;
position: relative;
bottom: 173px;
right: 2px;
margin: auto;
color: #007580;
height: 0;
font-family: 'Amiri', serif;
letter-spacing: -10px;
}
.R a {
text-decoration: none;
color: inherit;
}
.ICONwhatsnew {
position: relative;
margin: auto;
bottom: 194px;
right: 191px;
width: 0;
display: block;
height: 0;
}
.ICONwhatsnew a {
text-decoration: none;
color: inherit;
}
.ICONworldlanguages {
position: relative;
margin: auto;
bottom: 190px;
right: 116px;
width: 0;
display: block;
height: 0;
}
.ICONworldlanguages a {
text-decoration: none;
color: inherit;
}
.ICONsignin {
position: relative;
margin: auto;
bottom: 192px;
left: 83px;
width: 0;
display: block;
height: 0;
}
.ICONsignin a {
text-decoration: none;
color: inherit;
}
.ICONcart {
position: relative;
margin: auto;
bottom: 192px;
left: 149px;
width: 0;
display: block;
height: 0;
}
.ICONcart a {
text-decoration: none;
color: inherit;
}
.container {
font-size: 17px;
font-weight: 400;
color: #007580;
top: 50%;
left: 0;
right: 0;
position: absolute;
transform: translate(0, -50%);
}
input[type=unams] {
width: 80%;
padding: 12px 45px;
margin: 22px 0 0 0;
border: 1px solid #007580;
box-sizing: border-box;
border-radius: 0px;
-webkit-appearance: none;
font-size: 17px;
background-image: url('https://image.ibb.co/fZHHnc/signin.png');
background-position: 10px 8px;
background-repeat: no-repeat;
background-size: 25px;
}
input[type=password] {
width: 80%;
padding: 12px 45px;
/* first is how big you want the input box 2nd is positioning of word password */
margin: 22px 0 15px 0;
border: 1px solid #007580;
box-sizing: border-box;
border-radius: 0px;
-webkit-appearance: none;
font-size: 17px;
background-image: url('https://image.ibb.co/jC7gfx/lock.png');
background-position: 10px 8px;
background-repeat: no-repeat;
background-size: 25px;
}
.buttonlg {
background-color: #007580;
border: none;
color: white;
width: 25%;
font-size: 17px;
height: 38px;
margin: auto;
text-align: center;
}
.outerform {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.innerform {
width: 90%;
height: 90%;
}
.box {
position: relative;
background-color: white;
border: 1px solid #007580;
height: 100%;
}
.animate {
-webkit-animation: animatezoom 0.6s;
animation: animatezoom 0.6s
}
#-webkit-keyframes animatezoom {
from {
-webkit-transform: scale(0)
}
to {
-webkit-transform: scale(1)
}
}
::-webkit-input-placeholder {
/* WebKit browsers */
color: lightgrey;
opacity: 1 !important;
}
.circlelogo1 {
background: #007580;
border-radius: 50%;
height: 30px;
width: 30px;
position: relative;
margin: auto;
/*
Child elements with absolute positioning will be
positioned relative to this div
*/
}
.circlelogo2 {
position: absolute;
background: white;
border-radius: 50%;
height: 18px;
width: 18px;
/*
Put top edge and left edge in the center
*/
top: 50%;
left: 50%;
margin: -9px 0px 0px -9px;
/*
Offset the position correctly with
minus half of the width and minus half of the height
*/
}
<div class="outercircle"></div>
<div class="innercircle"></div>
<div class="D">
D
</div>
<div class="R">
R
</div>
<div class="quote">
You will always be your greatest investment.
</div>
<div class="searchcontainer">
<form>
<input name="search" placeholder="Search all resources..." type="text">
</form>
</div>
<div class="ICONsignin">
<img height="37px" src="https://svgshare.com/i/5SR.svg">
</div>
<div class="ICONcart">
<img height="39px" src="https://svgshare.com/i/5SE.svg">
</div>
<div class="ICONworldlanguages">
<img height="34px" src="https://svgshare.com/i/5XW.svg">
</div>
<div class="ICONwhatsnew">
<img height="43px" src="https://svgshare.com/i/5aX.svg">
</div>
<header>
<div class="categories">
<b>Categories</b> Newest Popular Music Youth
</div>
</header>
<main>
<section>
<div class="outerform">
<div class="innerform">
<form class="animate box">
<div class="container">
<div class="circlelogo1">
<div class="circlelogo2">
</div>
</div>
<input type="unams" placeholder="Username" name="uname" required>
<input type="password" placeholder="Password" name="psw" required><br>
<button class="buttonlg" type="submit">Log In</button>
</div>
</form>
</div>
</div>
</section>
</main>
<footer>
<div class="legal">
Contact Privacy Terms Copyright About
</div>
</footer>