How to balance progress bar dots - html

Any way to ensure that the green line is equal length to the left and between the dots on this line? Even when the browser is resized?
I am not sure what the best way to do it is. I can make the lines the same size but cannot keep the right-hand circle at the end, or just make it look visually balanced.
#wrapper1 {
display: flex;
left: 0px;
right: 0px;
}
#item1 {
box-sizing: border-box;
display: flex;
flex: 1 1 0%;
padding: 24px 0px 41px;
}
#item1:after {
content: '';
height: 3px;
width: 120.313px;
align-self: center;
background: rgb(124, 179, 66) none repeat scroll 0% 0% / auto padding-box border-box;
flex: 1 1 auto;
opacity: 0.5;
}
#item1:before {
content: '';
height: 3px;
width: 120.313px;
align-self: center;
background: rgb(124, 179, 66) none repeat scroll 0% 0% / auto padding-box border-box;
flex: 1 1 auto;
opacity: 0.5;
}
#label_wrapper_1 {
align-self: center;
}
#label_wrapper_1:before {
box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 0px 5px;
color: rgba(255, 255, 255, 0.87);
content: '✓';
display: inline-block;
height: 25px;
min-width: 25px;
text-align: center;
align-self: center;
background: rgb(124, 179, 66) none repeat scroll 0% 0% / auto padding-box border-box;
border-radius: 40px 40px 40px 40px;
}
#wrapper2 {
box-sizing: border-box;
display: flex;
flex: 1 1 0%;
padding: 24px 0px 41px;
}
#wrapper2:before {
content: '';
height: 3px;
text-align: center;
align-self: center;
background: rgb(124, 179, 66) none repeat scroll 0% 0% / auto padding-box border-box;
flex: 1 1 auto;
opacity: 0.5;
}
#label_wrapper_2:before {
box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 0px 5px;
color: rgba(255, 255, 255, 0.87);
content: '✓';
display: inline-block;
height: 25px;
text-align: center;
width: 25px;
background: rgb(124, 179, 66) none repeat scroll 0% 0% / auto padding-box border-box;
border-radius: 40px 40px 40px 40px;
}
<div id="wrapper1">
<div id="item1">
<div id="label_wrapper_1">
</div>
</div>
<div id="wrapper2">
<div id="label_wrapper_2">
</div>
</div>
</div>
A fiddle for your convenience:
http://jsfiddle.net/ha7uqe9x/3/
Ideally I would like it to look more like this:

is this?
#wrapper1 {
display: flex;
left: 0px;
right: 0px;
position:relative;
}
#item1 {
box-sizing: border-box;
display: flex;
flex: 1 1 0%;
padding: 24px 0px 41px;
position:absolute;
left:50%;
transform:translateX(-50%);
}
#item1:after {
content: '';
height: 3px;
width: 120.313px;
align-self: center;
background: rgb(124, 179, 66) none repeat scroll 0% 0% / auto padding-box border-box;
flex: 1 1 auto;
}
#item1:before {
content: '';
height: 3px;
width: 120.313px;
align-self: center;
background: rgb(124, 179, 66) none repeat scroll 0% 0% / auto padding-box border-box;
flex: 1 1 auto;
}
#label_wrapper_1 {
align-self: center;
}
#label_wrapper_1:before {
box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 0px 5px;
color: rgba(255, 255, 255, 0.87);
content: '✓';
display: inline-block;
height: 25px;
min-width: 25px;
text-align: center;
align-self: center;
background: rgb(124, 179, 66) none repeat scroll 0% 0% / auto padding-box border-box;
border-radius: 40px 40px 40px 40px;
}
#wrapper2 {
box-sizing: border-box;
display: flex;
flex: 1 1 0%;
padding: 24px 0px 41px;
}
#wrapper2:before {
content: '';
height: 3px;
text-align: center;
align-self: center;
background: rgb(124, 179, 66) none repeat scroll 0% 0% / auto padding-box border-box;
flex: 1 1 auto;
}
#label_wrapper_2:before {
box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 0px 5px;
color: rgba(255, 255, 255, 0.87);
content: '✓';
display: inline-block;
height: 25px;
text-align: center;
width: 25px;
background: rgb(124, 179, 66) none repeat scroll 0% 0% / auto padding-box border-box;
border-radius: 40px 40px 40px 40px;
}
<div id="wrapper1">
<div id="item1">
<div id="label_wrapper_1">
</div>
</div>
<div id="wrapper2">
<div id="label_wrapper_2">
</div>
</div>
</div>

Related

Clipped Button in css not as Expected

Expected
.clipped-button {
height: 42px;
min-width:120px;
width: auto;
display: block;
border:none;
border-radius:2px;
align-items:center;
clip-path: polygon(0px 0%, 0px 60%, 18px 100%, 100% 100%, 100% 40%, calc(100% - 18px) 0px);
padding: 2.625px;
background-color: #993029;
}
.btn {
width: 100%;
height: 100%;
background-color: rgb(205, 65, 58);
display:flex;
justify-content:center;
align-items:center;
clip-path: polygon(0px 0%, 0px 60%, 16px 100%, 100% 100%, 100% 40%, calc(100% - 16px) 0px);
color: rgb(255, 255, 255);
}
<button class="clipped-button"><div class="btn">Click Me</div>
</button>
Not getting the clipped corners rounded
Please help to round the clipped corners at top right and bottom left if possible
Rather than a clip-path perhaps something similar to the following is an option.
.button {
display: inline-block;
width: 200px;
height: 50px;
padding: 10px 20px;
font-size: 1.2em;
cursor: pointer;
text-align: center;
text-decoration: none;
justify-content: center;
align-items: center;
outline: none;
color: #fff;
border-radius: 25px;
border: 5px solid rgb(190, 40, 40);
background-color: rgba(200, 60, 60, 0.6);
background-image: linear-gradient(to bottom right, rgba(255,0,0,0), rgba(200, 60, 60, 0.8));
}
.button:hover {
box-shadow: 0 10px 10px 0 rgba(0,0,0,0.2);
/*--background-color: rgba(200, 60, 60, 1.0); --alt color--*/
background-image: linear-gradient(to bottom right, rgba(255,0,0,0), rgba(250, 100, 100, 1.0));
}
.button span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.5s;
}
.button span:after {
content: '\1F846 \1F846';
position: absolute;
opacity: 0;
top: -2px;
right: -40px;
transition: 0.5s;
}
.button:hover span {
padding-right: 40px;
}
.button:hover span:after {
opacity: 1;
right: 0;
}
<button class="button"><span> Click Me </span></button>

Figures on each other with decreasing size in HTLML - CSS

To get figures on one above the other, currently I am using the below method:-
<div id="box_cgf" class="box red"><figure class="c-green" id="cg1"><figure class="c-yellow" id="cy1"></figure></figure></div>
This is like, making one figure as parent and another as child. But, I do not want to use parent-child method. I would like to use as below:
*,
*:before,
*:after {
box-sizing: border-box;
margin: 0;
padding: 0;
}
.clearfix::after {
clear: both;
content: "";
display: table;
}
.container {
width: 500px;
height: 500px;
margin: auto;
margin-top: 80px;
cursor: pointer;
/* border: 1px solid black; */
}
.container-row1,
.container-row3 {
width: 100%;
height: 40%;
}
.row1-col1,
.row1-col3,
.row3-col1,
.row3-col3 {
height: 100%;
width: 40%;
}
}
.row1-col1,
.row1-col2,
.row1-col3,
.row2-col1,
.row2-col2,
.row2-col3,
.row3-col1,
.row3-col2,
.row3-col3 {
float: left;
}
.row1-col1,
.row1-col3,
.row3-col1,
.row3-col3 {
display: flex;
justify-content: center;
align-items: center;
}
.row1-col1-child,
.row1-col3-child,
.row3-col1-child,
.row3-col3-child {
width: 70%;
height: 70%;
}
.row1-col1-child>div,
.row1-col3-child>div,
.row3-col1-child>div,
.row3-col3-child>div {
width: 35%;
height: 35%;
float: left;
margin: 7.5%;
/* box-shadow: -2px 14px 28px rgba(0, 0, 0, 0.25), -2px 10px 10px rgba(0, 0, 0, 0.22); */
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
transition: all 0.3s cubic-bezier(.25, .8, .25, 1);
}
.row1-col1-child>div:hover,
.row1-col3-child>div:hover,
.row3-col1-child>div:hover,
.row3-col3-child>div:hover {
box-shadow: -2px 14px 28px rgba(0, 0, 0, 0.25), -2px 10px 10px rgba(0, 0, 0, 0.22);
}
.row1-col2>div,
.row3-col2>div {
width: 33.333%;
height: 16.667%;
float: left;
border: 1px solid black;
}
.red {
background-color: #dc2418;
}
.white {
background-color: #fff;
}
.card {
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.19), 0 6px 6px rgba(0, 0, 0, 0.23);
transition: all 0.3s cubic-bezier(.25, .8, .25, 1);
}
.card:hover {
box-shadow: 0 19px 38px rgba(0, 0, 0, 0.30), 0 15px 12px rgba(0, 0, 0, 0.22);
}
.c-yellow {
display: flex;
align-items: center;
margin: auto;
top: 0;
left: 0;
right: 0;
bottom: 0;
border-radius: 50%;
height: 90%;
width: 90%;
background: rgb(246, 243, 0);
background: radial-gradient(circle, rgba(246, 243, 0, 1) 5%, rgba(246, 243, 0, 1) 100%);
box-shadow: 1px 1px #888888;
}
.c-green {
display: flex;
align-items: center;
margin: auto;
top: 0;
left: 0;
right: 0;
bottom: 0;
border-radius: 50%;
height: 90%;
width: 90%;
background: rgb(97, 194, 31);
background: radial-gradient(circle, rgba(97, 194, 31, 1) 5%, rgba(97, 194, 31, 1) 100%);
box-shadow: 1px 1px #888888;
}
<!DOCTYPE html>
<html>
<body>
<div class="container card">
<!-- First row -->
<div class="container-row1 clearfix">
<div class="row1-col3">
<div class="row1-col3-child clearfix white">
<div id="box_cgf" class="box red">
<figure class="c-green" id="cg1"></figure>
<figure class="c-yellow" id="cy1"></figure>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
If you see its not getting one above the other, and its coming out of the div too.
Expected result is:-

figure on the center of its parent element using CSS

Trying to center the figure i.e .c-yellow , .c-blue but it didn't got center vertically. I need to center horizontally and vertically both:
*,
*:before,
*:after {
box-sizing: border-box;
margin: 0;
padding: 0;
}
.clearfix::after {
clear: both;
content: "";
display: table;
}
.container {
width: 500px;
height: 500px;
margin: auto;
margin-top: 80px;
cursor: pointer;
/* border: 1px solid black; */
}
.container-row1,
.container-row3 {
width: 100%;
height: 40%;
}
.row1-col1,
.row1-col3,
.row3-col1,
.row3-col3 {
height: 100%;
width: 40%;
}
}
.row1-col1,
.row1-col2,
.row1-col3,
.row2-col1,
.row2-col2,
.row2-col3,
.row3-col1,
.row3-col2,
.row3-col3 {
float: left;
}
.row1-col1,
.row1-col3,
.row3-col1,
.row3-col3 {
display: flex;
justify-content: center;
align-items: center;
}
.row1-col1-child,
.row1-col3-child,
.row3-col1-child,
.row3-col3-child {
width: 70%;
height: 70%;
}
.row1-col1-child>div,
.row1-col3-child>div,
.row3-col1-child>div,
.row3-col3-child>div {
width: 35%;
height: 35%;
float: left;
margin: 7.5%;
/* box-shadow: -2px 14px 28px rgba(0, 0, 0, 0.25), -2px 10px 10px rgba(0, 0, 0, 0.22); */
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
transition: all 0.3s cubic-bezier(.25, .8, .25, 1);
}
.row1-col1-child>div:hover,
.row1-col3-child>div:hover,
.row3-col1-child>div:hover,
.row3-col3-child>div:hover {
box-shadow: -2px 14px 28px rgba(0, 0, 0, 0.25), -2px 10px 10px rgba(0, 0, 0, 0.22);
}
.row1-col2>div,
.row3-col2>div {
width: 33.333%;
height: 16.667%;
float: left;
border: 1px solid black;
}
.yellow {
background-color: #f6c700;
}
.white {
background-color: #fff;
}
.card {
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.19), 0 6px 6px rgba(0, 0, 0, 0.23);
transition: all 0.3s cubic-bezier(.25, .8, .25, 1);
}
.card:hover {
box-shadow: 0 19px 38px rgba(0, 0, 0, 0.30), 0 15px 12px rgba(0, 0, 0, 0.22);
}
.c-yellow {
margin: auto;
top: 0;
left: 0;
right: 0;
bottom: 0;
border-radius: 50%;
height: 90%;
width: 90%;
border-radius: 50%;
height: 90%;
width: 90%;
background: rgb(246, 243, 0);
background: radial-gradient(circle, rgba(246, 243, 0, 1) 5%, rgba(246, 243, 0, 1) 100%);
box-shadow: 1px 1px #888888;
}
.c-blue {
margin: auto;
top: 0;
left: 0;
right: 0;
bottom: 0;
border-radius: 50%;
height: 90%;
width: 90%;
border-radius: 50%;
height: 90%;
width: 90%;
background: rgb(0, 243, 243);
background: radial-gradient(circle, rgba(0, 243, 243, 1) 5%, rgba(0, 243, 243, 1) 100%);
box-shadow: 1px 1px #888888;
}
<!DOCTYPE html>
<html>
<body>
<div class="container card">
<!-- First row -->
<div class="container-row1 clearfix">
<div class="row1-col3">
<div class="row1-col3-child clearfix white">
<div class="yellow">
<figure class="c-yellow">
<figure class="c-blue"></figure>
</figure>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
Trying to center the figure i.e .c-yellow , .c-blue but it didn't got center vertically. I need to center horizontally and vertically both.
Trying to center the figure i.e .c-yellow , .c-blue but it didn't got center vertically. I need to center horizontally and vertically both:
please use the below code to center vertically and horizontally
.yellow {
display: flex;
align-items: end;
justify-content: center;
}
.c-yellow {
display: flex;
align-items: center;
}
I added to .card, .row1-col1-child,.row1-col3-child,.row3-col1-child,.row3-col3-child ,.container-row1,.container-row3 classes
display: flex;
align-items: center;
justify-content:center;
css:
<style>
*,
*:before,
*:after {
box-sizing: border-box;
margin: 0;
padding: 0;
}
.clearfix::after {
clear: both;
content: "";
display: table;
}
.container {
width: 500px;
height: 500px;
margin: auto;
margin-top: 80px;
cursor: pointer;
/* border: 1px solid black; */
}
.container-row1,
.container-row3 {
width: 100%;
height: 40%;
display: flex;
align-items: center;
justify-content: center;
}
.row1-col1,
.row1-col3,
.row3-col1,
.row3-col3 {
height: 100%;
width: 40%;
}
.row1-col1,
.row1-col2,
.row1-col3,
.row2-col1,
.row2-col2,
.row2-col3,
.row3-col1,
.row3-col2,
.row3-col3 {
float: left;
}
.row1-col1,
.row1-col3,
.row3-col1,
.row3-col3 {
display: flex;
justify-content: center;
align-items: center;
}
.row1-col1-child,
.row1-col3-child,
.row3-col1-child,
.row3-col3-child {
width: 70%;
height: 70%;
display: flex;
align-items: center;
justify-content: center;
}
.row1-col1-child>div,
.row1-col3-child>div,
.row3-col1-child>div,
.row3-col3-child>div {
width: 35%;
height: 35%;
float: left;
margin: 7.5%;
/* box-shadow: -2px 14px 28px rgba(0, 0, 0, 0.25), -2px 10px 10px rgba(0, 0, 0, 0.22); */
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
transition: all 0.3s cubic-bezier(.25, .8, .25, 1);
}
.row1-col1-child>div:hover,
.row1-col3-child>div:hover,
.row3-col1-child>div:hover,
.row3-col3-child>div:hover {
box-shadow: -2px 14px 28px rgba(0, 0, 0, 0.25), -2px 10px 10px rgba(0, 0, 0, 0.22);
}
.row1-col2>div,
.row3-col2>div {
width: 33.333%;
height: 16.667%;
float: left;
border: 1px solid black;
}
.yellow {
background-color: #f6c700;
}
.white {
background-color: #fff;
}
.card {
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.19), 0 6px 6px rgba(0, 0, 0, 0.23);
transition: all 0.3s cubic-bezier(.25, .8, .25, 1);
display: flex;
align-items: center;
justify-content: center;
}
.card:hover {
box-shadow: 0 19px 38px rgba(0, 0, 0, 0.30), 0 15px 12px rgba(0, 0, 0, 0.22);
}
.c-yellow {
margin: auto;
top: 0;
left: 0;
right: 0;
bottom: 0;
border-radius: 50%;
height: 90%;
width: 90%;
border-radius: 50%;
height: 90%;
width: 90%;
background: rgb(246, 243, 0);
background: radial-gradient(circle, rgba(246, 243, 0, 1) 5%, rgba(246, 243, 0, 1) 100%);
box-shadow: 1px 1px #888888;
}
.c-blue {
margin: auto;
top: 0;
left: 0;
right: 0;
bottom: 0;
border-radius: 50%;
height: 90%;
width: 90%;
border-radius: 50%;
height: 90%;
width: 90%;
background: rgb(0, 243, 243);
background: radial-gradient(circle, rgba(0, 243, 243, 1) 5%, rgba(0, 243, 243, 1) 100%);
box-shadow: 1px 1px #888888;
}
</style>

Css input slider has weird positioning

I'm trying to get a input slider within another parent div. The
desired result looks like this:
The problem is when I try this the input slider gets a huge width, and
the height is messed up aswel.
I made Fiddle:
.wrapper {
display: inline-block;
width: 100%;
max-width: 100px;
background: #353434;
color: rgba(255, 255, 255, 0.9);
box-shadow: inset 0px 0px 4px 0px rgba(0, 0, 0, 0.75);
font-family: 'Raleway', 'Helvetica Neue', 'Helvetica', 'Arial'
}
.wrapper-header {
display: flex;
flex-flow: row nowrap;
justify-content: center;
padding: .5rem;
}
.wrapper-middle {
display: flex;
justify-content: center;
align-items: center;
}
.wrapper-end {
display: flex;
flex-flow: row nowrap;
justify-content: center;
height: 340px;
padding-top: 1rem;
padding-bottom: 1rem;
}
.slider-value {
min-width: 24px;
padding: .25rem;
border-radius: 2px;
color: #1fcc1f;
background: #333;
box-shadow: inset 0 0 3px 3px rgba(0, 0, 0, 0.5);
font-family: 'VT323', monospace;
text-align: center;
}
.button {
padding: .55rem;
border-radius: 2px;
background: linear-gradient(to bottom, #4f4f4f 0%, #0e0e0e 100%);
box-shadow: 0px 0px 1px 1px rgba(0, 0, 0, 0.5);
}
.wrapper-end-left {
height: 100%;
background: red;
}
.wrapper-end-right {
height: 100%;
background: blue;
}
[type='range'] {
-webkit-appearance: none; /* Hides the slider so that custom slider can be made */
margin: 0;
padding: 0;
width: 30rem;
height: 1.5em;
transform: rotate(-90deg);
background: transparent;
}
input[type=range]::-webkit-slider-thumb {
-webkit-appearance: none;
box-sizing: border-box;
border: none;
width: 1.5em; height: 1.5em;
border-radius: 50%;
background: #f90;
}
input[type=range]::-webkit-slider-runnable-track {
box-sizing: border-box;
border: none;
margin: 0;
padding: 0;
width: 100%; height: 100%;
background: #ccc;
}
<div class="wrapper">
<div class="wrapper-header">
<div class="button">
x
</div>
<div class="button">
x
</div>
</div>
<div class="wrapper-middle">
<div class="slider-value">
1
</div>
</div>
<div class="wrapper-end">
<div class="wrapper-end-left">
<input type="range">
</div>
<div class="wrapper-end-right">
two
</div>
</div>
</div>
Does someone know why this is happening?
Already read a lot here about input sliders but can't fix it.
https://css-tricks.com/styling-cross-browser-compatible-range-inputs-css/
https://codepen.io/freoted/pen/WGvxmN
https://jsfiddle.net/rwaldron/XukVc/
It is a little hacky but it resembles the desired layout now slightly closer - not tested to see how this would fare at different locations on the page or at different sizes. one of the key things that changed the layout was setting the transform-origin and tweaking the location with translate3d
document.addEventListener('DOMContentLoaded',(e)=>{
document.querySelector('[type="range"]').addEventListener('change',(e)=>{
document.querySelector('div.slider-value').textContent=e.target.value > 0 ? e.target.value : e.target.value * -1;
});
});
.wrapper {
display: inline-block;
width: 100%;
max-width: 100px;
background: #353434;
color: rgba(255, 255, 255, 0.9);
box-shadow: inset 0px 0px 4px 0px rgba(0, 0, 0, 0.75);
font-family: 'Raleway', 'Helvetica Neue', 'Helvetica', 'Arial'
}
.wrapper,.wrapper *{
box-sizing: border-box;
}
.wrapper-header {
display: flex;
flex-flow: row nowrap;
justify-content: center;
padding: .5rem;
}
.wrapper-middle {
display: flex;
justify-content: center;
align-items: center;
}
.wrapper-end {
display: flex;
flex-flow: row nowrap;
justify-content: center;
height: 340px;
padding-top: 1rem;
padding-bottom: 1rem;
}
.slider-value {
min-width: 24px;
padding: .25rem;
border-radius: 2px;
color: #1fcc1f;
background: #333;
box-shadow: inset 0 0 3px 3px rgba(0, 0, 0, 0.5);
font-family: 'VT323', monospace;
text-align: center;
}
.button {
padding:0.55rem;
border-radius:2px;
background: linear-gradient(to bottom, #4f4f4f 0%, #0e0e0e 100%);
box-shadow: 0px 0px 1px 1px rgba(0, 0, 0, 0.5);
}
.wrapper-end-left {
height: 100%;
padding:0;
margin:0 1.25rem 0 0;
display:flex;
flex-direction:column;
flex-wrap:no-wrap;
align-content:center;
justify-content:stretch;
}
.wrapper-end-right {
height:100%;
width:0.75rem!important;
background:linear-gradient(0deg, rgba(13,60,2,1) 0%, rgba(57,241,17,1) 79%, rgba(245,157,63,1) 92%, rgba(255,0,0,1) 100%);
}
.wrapper-end-left,
.wrapper-end-right{
width:2rem;
}
[type='range'] {
-webkit-appearance:none;
margin:0;
padding:0;
flex:1;
height:1.5rem;
width:19.2rem;
transform-origin:5% 50%;
transform:rotate(-90deg) translate3d( -8.6rem, -0.25rem, 0 );
background:transparent;
outline:0;
}
input[type=range]::-webkit-slider-thumb {
-webkit-appearance:none;
border:none;
width:1.5em;
height:1.5em;
border-radius:50%;
background:black;
border:2px solid silver;
margin:-0.35rem 0 0 0;
}
input[type=range]::-webkit-slider-runnable-track {
box-sizing:border-box;
border:none;
margin:0;
padding:0;
height:0.5rem;
flex:1;
background:#ccc;
}
<div class="wrapper">
<div class="wrapper-header">
<div class="button">x</div>
<div class="button">x</div>
</div>
<div class="wrapper-middle">
<div class="slider-value">0</div>
</div>
<div class="wrapper-end">
<div class="wrapper-end-left"><input type="range" step=3 min=-60 max=12 value=0 /></div>
<div class="wrapper-end-right"> </div>
</div>
</div>

how to center bigger div under smaller div [duplicate]

This question already has answers here:
center overflowing div inside smaller div
(1 answer)
Larger div centered inside smaller div
(3 answers)
How can I horizontally center an element?
(133 answers)
Closed 4 years ago.
I have a login page that is absolutely centered in the middle of the page both horizontally and vertically.
Inside there are 2 divs, smaller pink one and bigger blue one.
How can I center the bigger one?
.container {
background: rgba(249, 249, 249, 1);
bottom: 0;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 1), 0 0px 4px 0 rgba(0, 0, 0, 1);
height: 342px;
height: max-content;
left: 0;
margin: auto;
padding: 60px 30px 60px 30px;
position: absolute;
right: 0;
top: 0;
width: 300px;
overflow: visible;
}
.smaller {
background: pink;
}
button {
background: linear-gradient(rgba(239, 83, 80, 1), rgba(179, 47, 47, 1));
border: 0;
color: rgba(255, 255, 255, 1);
margin: 10px;
padding: 8px 70px 8px 20px;
box-sizing: content-box;
width: 50px;
}
.bigger {
width: 400px;
text-align: center;
background: blue
}
<div class="container">
<div class="smaller pink">
<h2>Sign In</h2>
<input>
</div>
<div class="bigger blue">
<button>Back</button><button>Login</button>
</div>
</div>
.container {
background: rgba(249, 249, 249, 1);
bottom: 0;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 1), 0 0px 4px 0 rgba(0, 0, 0, 1);
height: 342px;
height: max-content;
left: 0;
margin: auto;
padding: 60px 30px 60px 30px;
position: absolute;
right: 0;
top: 0;
width: 300px;
overflow: visible;
}
.smaller {
background: pink;
}
button {
background: linear-gradient(rgba(239, 83, 80, 1), rgba(179, 47, 47, 1));
border: 0;
color: rgba(255, 255, 255, 1);
margin: 10px;
padding: 8px 70px 8px 20px;
box-sizing: content-box;
width: 50px;
}
.bigger {
width: 400px;
text-align: center;
background: blue;
margin: auto;
left: 50%;
transform: translateX(-50%);
position: absolute;
}
<div class="container">
<div class="smaller pink">
<h2>Sign In</h2>
<input>
</div>
<div class="bigger blue">
<button>Back</button><button>Login</button>
</div>
</div>
Just set width to 100%
.container {
background: rgba(249, 249, 249, 1);
bottom: 0;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 1), 0 0px 4px 0 rgba(0, 0, 0, 1);
height: 342px;
height: max-content;
left: 0;
margin: auto;
padding: 60px 30px 60px 30px;
position: absolute;
right: 0;
top: 0;
width: 300px;
overflow: visible;
}
.smaller {
background: pink;
}
button {
background: linear-gradient(rgba(239, 83, 80, 1), rgba(179, 47, 47, 1));
border: 0;
color: rgba(255, 255, 255, 1);
margin: 10px;
padding: 8px 70px 8px 20px;
box-sizing: content-box;
width: 50px;
}
.bigger {
width: 100%;
text-align: center;
background: blue
}
<div class="container">
<div class="smaller pink">
<h2>Sign In</h2>
<input>
</div>
<div class="bigger blue">
<button>Back</button><button>Login</button>
</div>
</div>
I think this will help you
.container {
background: rgba(249, 249, 249, 1);
bottom: 0;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 1), 0 0px 4px 0 rgba(0, 0, 0, 1);
height: 342px;
height: max-content;
left: 0;
margin: auto;
padding: 60px 30px 60px 30px;
position: absolute;
right: 0;
top: 0;
width: 450px;
overflow: visible;
}
.smaller {
background: pink;
width: 300px;
margin:auto;
}
button {
background: linear-gradient(rgba(239, 83, 80, 1), rgba(179, 47, 47, 1));
border: 0;
color: rgba(255, 255, 255, 1);
margin: 10px;
padding: 8px 70px 8px 20px;
box-sizing: content-box;
width: 50px;
}
.bigger {
width: 400px;
text-align: center;
background: blue;
margin:auto;
}
<div class="container">
<div class="smaller pink">
<h2>Sign In</h2>
<input>
</div>
<div class="bigger blue">
<button>Back</button><button>Login</button>
</div>
</div>
You may want to consider using flexbox which also is responsive by nature.
.container {
background: rgba(249, 249, 249, 1);
bottom: 0;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 1), 0 0px 4px 0 rgba(0, 0, 0, 1);
height: 342px;
height: max-content;
left: 0;
margin: auto;
padding: 60px 30px 60px 30px;
position: absolute;
right: 0;
top: 0;
width: 300px;
overflow: visible;
}
.smaller {
background: pink;
}
button {
background: linear-gradient(rgba(239, 83, 80, 1), rgba(179, 47, 47, 1));
border: 0;
color: rgba(255, 255, 255, 1);
margin: 10px;
padding: 8px 70px 8px 20px;
box-sizing: content-box;
width: 50px;
}
.bigger {
display: flex;
background: blue;
justify-content: space-around;
}
<div class="container">
<div class="smaller pink">
<h2>Sign In</h2>
<input>
</div>
<div class="bigger blue">
<button>Back</button><button>Login</button>
</div>
</div>