I want the spinner to be placed here as a part of the submit input button:
But I'm unable to find a proper solution, here is what I tried:
/*button itself*/
.btn {
font-family: "iransansdnlight";
max-width: 200px;
width: 100%;
background-color: #ad69f4;
border: none;
outline: none;
height: 40px;
border-radius: 49px;
color: #fff;
text-transform: uppercase;
font-weight: 600;
margin: 5px 0;
margin-top: 15px;
cursor: pointer;
transition: 0.5s;
opacity: 1;
}
.btn:not(.disabled):hover {
background-color: #9f5ae7;
}
/*Submit Spinner*/
.submit-container {
display: flex;
flex-direction: row;
max-width: 200px;
width: 100%;
}
.spinner {
font-size: 20px;
position: relative;
display: inline-block;
width: 1em;
height: 1em;
}
.spinner.center {
left: 0;
right: 0;
top: 0;
bottom: 0;
margin: auto;
}
.spinner-blade {
position: absolute;
left: 0.4629em;
bottom: 0;
width: 0.074em;
height: 0.2777em;
border-radius: 0.5em;
background-color: transparent;
transform-origin: center -0.2222em;
-webkit-animation: spinner-fade 1s infinite linear;
animation: spinner-fade 1s infinite linear;
}
.spinner-blade:nth-child(1) {
-webkit-animation-delay: 0s;
animation-delay: 0s;
transform: rotate(0deg);
}
.spinner-blade:nth-child(2) {
-webkit-animation-delay: 0.083s;
animation-delay: 0.083s;
transform: rotate(30deg);
}
.spinner-blade:nth-child(3) {
-webkit-animation-delay: 0.166s;
animation-delay: 0.166s;
transform: rotate(60deg);
}
.spinner-blade:nth-child(4) {
-webkit-animation-delay: 0.249s;
animation-delay: 0.249s;
transform: rotate(90deg);
}
.spinner-blade:nth-child(5) {
-webkit-animation-delay: 0.332s;
animation-delay: 0.332s;
transform: rotate(120deg);
}
.spinner-blade:nth-child(6) {
-webkit-animation-delay: 0.415s;
animation-delay: 0.415s;
transform: rotate(150deg);
}
.spinner-blade:nth-child(7) {
-webkit-animation-delay: 0.498s;
animation-delay: 0.498s;
transform: rotate(180deg);
}
.spinner-blade:nth-child(8) {
-webkit-animation-delay: 0.581s;
animation-delay: 0.581s;
transform: rotate(210deg);
}
.spinner-blade:nth-child(9) {
-webkit-animation-delay: 0.664s;
animation-delay: 0.664s;
transform: rotate(240deg);
}
.spinner-blade:nth-child(10) {
-webkit-animation-delay: 0.747s;
animation-delay: 0.747s;
transform: rotate(270deg);
}
.spinner-blade:nth-child(11) {
-webkit-animation-delay: 0.83s;
animation-delay: 0.83s;
transform: rotate(300deg);
}
.spinner-blade:nth-child(12) {
-webkit-animation-delay: 0.913s;
animation-delay: 0.913s;
transform: rotate(330deg);
}
#-webkit-keyframes spinner-fade {
0% {
background-color: #69717d;
}
100% {
background-color: transparent;
}
}
#keyframes spinner-fade {
0% {
background-color: #69717d;
}
100% {
background-color: transparent;
}
}
<div class="submit-container">
<div class="spinner center">
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
</div>
<input class="btn submit disabled" id="submit-register" type="submit" value="ثبت نام" />
</div>
You need to use position:absolute instead of relative.
You can position it 50% from top. And since the width/height of the spinner is known, you can use a negative top margin to give some offset based on the center of the spinner.
/*button itself*/
.btn {
font-family: "iransansdnlight";
max-width: 200px;
width: 100%;
background-color: #ad69f4;
border: none;
outline: none;
height: 40px;
border-radius: 49px;
color: #fff;
text-transform: uppercase;
font-weight: 600;
margin: 5px 0;
margin-top: 15px;
cursor: pointer;
transition: 0.5s;
opacity: 1;
}
.btn:not(.disabled):hover {
background-color: #9f5ae7;
}
/*Submit Spinner*/
.submit-container {
display: flex;
flex-direction: row;
max-width: 200px;
width: 100%;
position: relative;
}
.spinner {
font-size: 20px;
position: absolute;
display: inline-block;
width: 1em;
height: 1em;
}
.spinner.center {
left: 7.5%;
top: 50%;
margin-top: -5px;
}
.spinner-blade {
position: absolute;
left: 0.4629em;
bottom: 0;
width: 0.074em;
height: 0.2777em;
border-radius: 0.5em;
background-color: transparent;
transform-origin: center -0.2222em;
-webkit-animation: spinner-fade 1s infinite linear;
animation: spinner-fade 1s infinite linear;
}
.spinner-blade:nth-child(1) {
-webkit-animation-delay: 0s;
animation-delay: 0s;
transform: rotate(0deg);
}
.spinner-blade:nth-child(2) {
-webkit-animation-delay: 0.083s;
animation-delay: 0.083s;
transform: rotate(30deg);
}
.spinner-blade:nth-child(3) {
-webkit-animation-delay: 0.166s;
animation-delay: 0.166s;
transform: rotate(60deg);
}
.spinner-blade:nth-child(4) {
-webkit-animation-delay: 0.249s;
animation-delay: 0.249s;
transform: rotate(90deg);
}
.spinner-blade:nth-child(5) {
-webkit-animation-delay: 0.332s;
animation-delay: 0.332s;
transform: rotate(120deg);
}
.spinner-blade:nth-child(6) {
-webkit-animation-delay: 0.415s;
animation-delay: 0.415s;
transform: rotate(150deg);
}
.spinner-blade:nth-child(7) {
-webkit-animation-delay: 0.498s;
animation-delay: 0.498s;
transform: rotate(180deg);
}
.spinner-blade:nth-child(8) {
-webkit-animation-delay: 0.581s;
animation-delay: 0.581s;
transform: rotate(210deg);
}
.spinner-blade:nth-child(9) {
-webkit-animation-delay: 0.664s;
animation-delay: 0.664s;
transform: rotate(240deg);
}
.spinner-blade:nth-child(10) {
-webkit-animation-delay: 0.747s;
animation-delay: 0.747s;
transform: rotate(270deg);
}
.spinner-blade:nth-child(11) {
-webkit-animation-delay: 0.83s;
animation-delay: 0.83s;
transform: rotate(300deg);
}
.spinner-blade:nth-child(12) {
-webkit-animation-delay: 0.913s;
animation-delay: 0.913s;
transform: rotate(330deg);
}
#-webkit-keyframes spinner-fade {
0% {
background-color: #69717d;
}
100% {
background-color: transparent;
}
}
#keyframes spinner-fade {
0% {
background-color: #69717d;
}
100% {
background-color: transparent;
}
}
<div class="submit-container">
<div class="spinner center">
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
</div>
<input class="btn submit disabled" id="submit-register" type="submit" value="ثبت نام" />
</div>
You have used absolute positioning, so you only need to tweak the left and top attributes of the .spinner.center. I also took the liberty to change the color of your blades, so they are in contrast with the background.
/*button itself*/
.btn {
font-family: "iransansdnlight";
max-width: 200px;
width: 100%;
background-color: #ad69f4;
border: none;
outline: none;
height: 40px;
border-radius: 49px;
color: #fff;
text-transform: uppercase;
font-weight: 600;
margin: 5px 0;
margin-top: 15px;
cursor: pointer;
transition: 0.5s;
opacity: 1;
}
.btn:not(.disabled):hover {
background-color: #9f5ae7;
}
/*Submit Spinner*/
.submit-container {
display: flex;
flex-direction: row;
max-width: 200px;
width: 100%;
}
.spinner {
font-size: 20px;
position: relative;
display: inline-block;
width: 1em;
height: 1em;
}
.spinner.center {
left: 28px;
top: 6px;
margin: auto;
}
.spinner-blade {
position: absolute;
left: 0.4629em;
bottom: 0;
width: 0.074em;
height: 0.2777em;
border-radius: 0.5em;
background-color: transparent;
transform-origin: center -0.2222em;
-webkit-animation: spinner-fade 1s infinite linear;
animation: spinner-fade 1s infinite linear;
}
.spinner-blade:nth-child(1) {
-webkit-animation-delay: 0s;
animation-delay: 0s;
transform: rotate(0deg);
}
.spinner-blade:nth-child(2) {
-webkit-animation-delay: 0.083s;
animation-delay: 0.083s;
transform: rotate(30deg);
}
.spinner-blade:nth-child(3) {
-webkit-animation-delay: 0.166s;
animation-delay: 0.166s;
transform: rotate(60deg);
}
.spinner-blade:nth-child(4) {
-webkit-animation-delay: 0.249s;
animation-delay: 0.249s;
transform: rotate(90deg);
}
.spinner-blade:nth-child(5) {
-webkit-animation-delay: 0.332s;
animation-delay: 0.332s;
transform: rotate(120deg);
}
.spinner-blade:nth-child(6) {
-webkit-animation-delay: 0.415s;
animation-delay: 0.415s;
transform: rotate(150deg);
}
.spinner-blade:nth-child(7) {
-webkit-animation-delay: 0.498s;
animation-delay: 0.498s;
transform: rotate(180deg);
}
.spinner-blade:nth-child(8) {
-webkit-animation-delay: 0.581s;
animation-delay: 0.581s;
transform: rotate(210deg);
}
.spinner-blade:nth-child(9) {
-webkit-animation-delay: 0.664s;
animation-delay: 0.664s;
transform: rotate(240deg);
}
.spinner-blade:nth-child(10) {
-webkit-animation-delay: 0.747s;
animation-delay: 0.747s;
transform: rotate(270deg);
}
.spinner-blade:nth-child(11) {
-webkit-animation-delay: 0.83s;
animation-delay: 0.83s;
transform: rotate(300deg);
}
.spinner-blade:nth-child(12) {
-webkit-animation-delay: 0.913s;
animation-delay: 0.913s;
transform: rotate(330deg);
}
#-webkit-keyframes spinner-fade {
0% {
background-color: white;
}
100% {
background-color: transparent;
}
}
#keyframes spinner-fade {
0% {
background-color: white;
}
100% {
background-color: transparent;
}
}
<div class="submit-container">
<div class="spinner center">
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
</div>
<input class="btn submit disabled" id="submit-register" type="submit" value="ثبت نام" />
</div>
Related
I have two elements in which I want to mix them together, a button and a simple loader. each element works fine alone but I want to have them together so that the loader be positioned at the center of the button and still the style of the form doesn't ruin...
Here is the loader alone:
Note that if disabled class is attached to submit-container the loader would be visible:
.btn {
font-family: "IRANSansWeb";
max-width: 200px;
width: 100%;
height: 40px;
font-weight: 600;
margin: 5px 0;
margin-top: 15px;
cursor: pointer;
opacity: 1;
background: linear-gradient(to right, #9672fb, #d772fb);
border-radius: 30px;
border: none;
color: white;
box-shadow: 0px 5px 10px -3px rgb(0 0 0 / 37%);
transition: 0.2s;
}
.submit-container:not(.disabled) .btn:active {
transform: translateY(5px) !important;
box-shadow: none !important;
}
.submit-container:not(.disabled) .btn:hover {
transform: translateY(1px);
box-shadow: 0px 2px 5px -1px rgb(0 0 0 / 30%);
}
.submit-container.disabled .submit {
opacity: 0.5;
cursor: default;
}
.submit-container.disabled .spinner {
display: inline-block;
}
.submit-container {
display: flex;
flex-direction: row;
max-width: 200px;
width: 100%;
position: relative;
}
.modal .submit-container {
height: 70px;
}
.spinner {
font-size: 20px;
position: absolute;
display: none;
width: 1em;
height: 1em;
}
.spinner.center {
left: 8%;
top: 50%;
margin-top: -5px;
}
.spinner-blade {
position: absolute;
left: 0.4629em;
bottom: 0;
width: 0.074em;
height: 0.2777em;
border-radius: 0.5em;
background-color: transparent;
transform-origin: center -0.2222em;
-webkit-animation: spinner-fade 1s infinite linear;
animation: spinner-fade 1s infinite linear;
}
.spinner-blade:nth-child(1) {
-webkit-animation-delay: 0s;
animation-delay: 0s;
transform: rotate(0deg);
}
.spinner-blade:nth-child(2) {
-webkit-animation-delay: 0.083s;
animation-delay: 0.083s;
transform: rotate(30deg);
}
.spinner-blade:nth-child(3) {
-webkit-animation-delay: 0.166s;
animation-delay: 0.166s;
transform: rotate(60deg);
}
.spinner-blade:nth-child(4) {
-webkit-animation-delay: 0.249s;
animation-delay: 0.249s;
transform: rotate(90deg);
}
.spinner-blade:nth-child(5) {
-webkit-animation-delay: 0.332s;
animation-delay: 0.332s;
transform: rotate(120deg);
}
.spinner-blade:nth-child(6) {
-webkit-animation-delay: 0.415s;
animation-delay: 0.415s;
transform: rotate(150deg);
}
.spinner-blade:nth-child(7) {
-webkit-animation-delay: 0.498s;
animation-delay: 0.498s;
transform: rotate(180deg);
}
.spinner-blade:nth-child(8) {
-webkit-animation-delay: 0.581s;
animation-delay: 0.581s;
transform: rotate(210deg);
}
.spinner-blade:nth-child(9) {
-webkit-animation-delay: 0.664s;
animation-delay: 0.664s;
transform: rotate(240deg);
}
.spinner-blade:nth-child(10) {
-webkit-animation-delay: 0.747s;
animation-delay: 0.747s;
transform: rotate(270deg);
}
.spinner-blade:nth-child(11) {
-webkit-animation-delay: 0.83s;
animation-delay: 0.83s;
transform: rotate(300deg);
}
.spinner-blade:nth-child(12) {
-webkit-animation-delay: 0.913s;
animation-delay: 0.913s;
transform: rotate(330deg);
}
#-webkit-keyframes spinner-fade {
0% {
background-color: #51386b;
}
100% {
background-color: transparent;
}
}
#keyframes spinner-fade {
0% {
background-color: #51386b;
}
100% {
background-color: transparent;
}
}
<div class="submit-container disabled">
<div class="spinner center">
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
</div>
</div>
Now I try to have both button and loader together:
.btn {
font-family: "IRANSansWeb";
max-width: 200px;
width: 100%;
height: 40px;
font-weight: 600;
margin: 5px 0;
margin-top: 15px;
cursor: pointer;
opacity: 1;
background: linear-gradient(to right, #9672fb, #d772fb);
border-radius: 30px;
border: none;
color: white;
box-shadow: 0px 5px 10px -3px rgb(0 0 0 / 37%);
transition: 0.2s;
}
.submit-container:not(.disabled) .btn:active {
transform: translateY(5px) !important;
box-shadow: none !important;
}
.submit-container:not(.disabled) .btn:hover {
transform: translateY(1px);
box-shadow: 0px 2px 5px -1px rgb(0 0 0 / 30%);
}
.submit-container.disabled .submit {
opacity: 0.5;
cursor: default;
}
.submit-container.disabled .spinner {
display: inline-block;
}
.submit-container {
display: flex;
flex-direction: row;
max-width: 200px;
width: 100%;
position: relative;
}
.modal .submit-container {
height: 70px;
}
.spinner {
font-size: 20px;
position: absolute;
display: none;
width: 1em;
height: 1em;
}
.spinner.center {
left: 8%;
top: 50%;
margin-top: -5px;
}
.spinner-blade {
position: absolute;
left: 0.4629em;
bottom: 0;
width: 0.074em;
height: 0.2777em;
border-radius: 0.5em;
background-color: transparent;
transform-origin: center -0.2222em;
-webkit-animation: spinner-fade 1s infinite linear;
animation: spinner-fade 1s infinite linear;
}
.spinner-blade:nth-child(1) {
-webkit-animation-delay: 0s;
animation-delay: 0s;
transform: rotate(0deg);
}
.spinner-blade:nth-child(2) {
-webkit-animation-delay: 0.083s;
animation-delay: 0.083s;
transform: rotate(30deg);
}
.spinner-blade:nth-child(3) {
-webkit-animation-delay: 0.166s;
animation-delay: 0.166s;
transform: rotate(60deg);
}
.spinner-blade:nth-child(4) {
-webkit-animation-delay: 0.249s;
animation-delay: 0.249s;
transform: rotate(90deg);
}
.spinner-blade:nth-child(5) {
-webkit-animation-delay: 0.332s;
animation-delay: 0.332s;
transform: rotate(120deg);
}
.spinner-blade:nth-child(6) {
-webkit-animation-delay: 0.415s;
animation-delay: 0.415s;
transform: rotate(150deg);
}
.spinner-blade:nth-child(7) {
-webkit-animation-delay: 0.498s;
animation-delay: 0.498s;
transform: rotate(180deg);
}
.spinner-blade:nth-child(8) {
-webkit-animation-delay: 0.581s;
animation-delay: 0.581s;
transform: rotate(210deg);
}
.spinner-blade:nth-child(9) {
-webkit-animation-delay: 0.664s;
animation-delay: 0.664s;
transform: rotate(240deg);
}
.spinner-blade:nth-child(10) {
-webkit-animation-delay: 0.747s;
animation-delay: 0.747s;
transform: rotate(270deg);
}
.spinner-blade:nth-child(11) {
-webkit-animation-delay: 0.83s;
animation-delay: 0.83s;
transform: rotate(300deg);
}
.spinner-blade:nth-child(12) {
-webkit-animation-delay: 0.913s;
animation-delay: 0.913s;
transform: rotate(330deg);
}
#-webkit-keyframes spinner-fade {
0% {
background-color: #51386b;
}
100% {
background-color: transparent;
}
}
#keyframes spinner-fade {
0% {
background-color: #51386b;
}
100% {
background-color: transparent;
}
}
.settings-input label{
align-self: flex-start;
margin-bottom: 3px;
font-size: 13px;
color: #a697bb;
}
.settings-input .input-field {
display: flex;
flex-direction: column;
margin: 15px;
}
.settings-input div,
.settings-input .input-field,
.settings-input input {
position: relative;
}
.settings-input .container {
width: 300px;
display: flex;
align-items: center;
}
.settings-input button {
text-align: center;
font-family: "IRANSansWeb_Light";
font-size: 11.5px;
position: absolute;
left: 0;
background-color: #8f7cff;
outline: none;
border: none;
color: #00eff3;
cursor: pointer;
padding: 3.5px 0;
direction: ltr;
width: 3rem;
}
.settings-input button:hover {
color: white;
background-color: #9e91ef;
}
.settings-input input {
font-family: "Open Sans";
font-size: 13px;
display: inline-block;
direction: ltr;
text-align: center;
outline: none;
width: 300px;
background: #edc3ff4a;
color: #743db0;
padding: 4px 4px;
border-radius: 3px;
border: solid 1px;
border-color: transparent;
transition: all 0.3s ease-in;
padding-left: 1.2rem;
}
.settings-input input:focus {
color: #8e5bc5;
background: #fff;
border-color: #e38fff;
}
<div class="settings-input">
<div class="input-field">
<label>phone</label>
<div id="phone-input" class="container">
<input type="text" placeholder="enter your phone" />
<div class="submit-container disabled">
<div class="spinner center">
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
</div>
<button>apply</button>
</div>
</div>
</div>
<div class="input-field">
<label>email</label>
<div id="email-input" class="container">
<input type="email" placeholder="enter your email" />
<button>apply</button>
</div>
</div>
</div>
As you see the style of the form ruins and even the loader distortion occurs...
I just want to place the loader at the center of the button without ruining the form style..
How can I do this?
I did not improve the code as much as I had written in the comment. But this just fixes your issue. You can improve the layout a bit more later on.
The issue is that position: relative will create a new layout context. In this context, everything can be layered along the z-axis and all the child elements that have position: absolute will refer to the nearest relative parent. Therefore, you get this distortion effect.
Removed this ...
.settings-input div,
.settings-input .input-field,
.settings-input input {
position: relative;
}
Added that ...
button { [...] position: relative; }
And I moved the spinner inside the button.
Here you go:
.btn {
font-family: "IRANSansWeb";
max-width: 200px;
width: 100%;
height: 40px;
font-weight: 600;
margin: 5px 0;
margin-top: 15px;
cursor: pointer;
opacity: 1;
background: linear-gradient(to right, #9672fb, #d772fb);
border-radius: 30px;
border: none;
color: white;
box-shadow: 0px 5px 10px -3px rgb(0 0 0 / 37%);
transition: 0.2s;
}
.submit-container:not(.disabled) .btn:active {
transform: translateY(5px) !important;
box-shadow: none !important;
}
.submit-container:not(.disabled) .btn:hover {
transform: translateY(1px);
box-shadow: 0px 2px 5px -1px rgb(0 0 0 / 30%);
}
.submit-container.disabled .submit {
opacity: 0.5;
cursor: default;
}
.submit-container.disabled .spinner {
display: inline-block;
}
.submit-container {
display: flex;
flex-direction: row;
max-width: 200px;
width: 100%;
position: relative;
}
.modal .submit-container {
height: 70px;
}
.spinner {
font-size: 20px;
position: absolute;
display: none;
width: 1em;
height: 1em;
}
.spinner.center {
left: 8%;
top: 50%;
transform: translateY(-50%)
}
.spinner-blade {
position: absolute;
left: 0.4629em;
bottom: 0;
width: 0.074em;
height: 0.2777em;
border-radius: 0.5em;
background-color: transparent;
transform-origin: center -0.2222em;
-webkit-animation: spinner-fade 1s infinite linear;
animation: spinner-fade 1s infinite linear;
}
.spinner-blade:nth-child(1) {
-webkit-animation-delay: 0s;
animation-delay: 0s;
transform: rotate(0deg);
}
.spinner-blade:nth-child(2) {
-webkit-animation-delay: 0.083s;
animation-delay: 0.083s;
transform: rotate(30deg);
}
.spinner-blade:nth-child(3) {
-webkit-animation-delay: 0.166s;
animation-delay: 0.166s;
transform: rotate(60deg);
}
.spinner-blade:nth-child(4) {
-webkit-animation-delay: 0.249s;
animation-delay: 0.249s;
transform: rotate(90deg);
}
.spinner-blade:nth-child(5) {
-webkit-animation-delay: 0.332s;
animation-delay: 0.332s;
transform: rotate(120deg);
}
.spinner-blade:nth-child(6) {
-webkit-animation-delay: 0.415s;
animation-delay: 0.415s;
transform: rotate(150deg);
}
.spinner-blade:nth-child(7) {
-webkit-animation-delay: 0.498s;
animation-delay: 0.498s;
transform: rotate(180deg);
}
.spinner-blade:nth-child(8) {
-webkit-animation-delay: 0.581s;
animation-delay: 0.581s;
transform: rotate(210deg);
}
.spinner-blade:nth-child(9) {
-webkit-animation-delay: 0.664s;
animation-delay: 0.664s;
transform: rotate(240deg);
}
.spinner-blade:nth-child(10) {
-webkit-animation-delay: 0.747s;
animation-delay: 0.747s;
transform: rotate(270deg);
}
.spinner-blade:nth-child(11) {
-webkit-animation-delay: 0.83s;
animation-delay: 0.83s;
transform: rotate(300deg);
}
.spinner-blade:nth-child(12) {
-webkit-animation-delay: 0.913s;
animation-delay: 0.913s;
transform: rotate(330deg);
}
#-webkit-keyframes spinner-fade {
0% {
background-color: #51386b;
}
100% {
background-color: transparent;
}
}
#keyframes spinner-fade {
0% {
background-color: #51386b;
}
100% {
background-color: transparent;
}
}
.settings-input label {
align-self: flex-start;
margin-bottom: 3px;
font-size: 13px;
color: #a697bb;
}
.settings-input .input-field {
display: flex;
flex-direction: column;
margin: 15px;
}
.settings-input .container {
width: 300px;
display: flex;
align-items: center;
}
.settings-input button {
text-align: center;
font-family: "IRANSansWeb_Light";
font-size: 11.5px;
position: relative;
left: 0;
background-color: #8f7cff;
outline: none;
border: none;
color: #00eff3;
cursor: pointer;
padding: 3.5px 0;
direction: ltr;
width: 3rem;
}
.settings-input button:hover {
color: white;
background-color: #9e91ef;
}
.settings-input input {
font-family: "Open Sans";
font-size: 13px;
direction: ltr;
text-align: center;
outline: none;
width: 300px;
background: #edc3ff4a;
color: #743db0;
padding: 4px 4px;
border-radius: 3px;
border: solid 1px;
border-color: transparent;
transition: all 0.3s ease-in;
padding-left: 1.2rem;
box-sizing: border-box;
}
.settings-input input:focus {
color: #8e5bc5;
background: #fff;
border-color: #e38fff;
}
<div class="settings-input">
<div class="input-field">
<label>phone</label>
<div id="phone-input" class="container">
<input type="text" placeholder="enter your phone" />
<div class="submit-container disabled">
<button>
<div class="spinner center">
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
<div class="spinner-blade"></div>
</div>
<span>apply</span>
</button>
</div>
</div>
</div>
<div class="input-field">
<label>email</label>
<div id="email-input" class="container">
<input type="email" placeholder="enter your email" />
<button>apply</button>
</div>
</div>
</div>
Please see the code below.
.nk-loader-c {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.nk-loader-circle {
transform-origin: bottom center;
animation: obj-rotate 3s linear infinite;
height: 36px;
}
.obj-circle {
display: inline-block;
background-color: #6540eb;
height: 20px;
width: 20px;
border-radius: 50%;
transform: scale(0);
animation: obj-grow 1.5s linear infinite;
margin: -5px;
}
.obj-circle:nth-child(1) {
background-color: #3766f3;
animation-delay: 1.5s;
}
.obj-circle:nth-child(2) {
background-color: #603aef;
animation-delay: .75s;
}
.obj-circle:nth-child(3) {
background-color: #2998f6;
animation-delay: .37s;
}
#keyframes obj-rotate {
to{
transform: rotate(360deg);
}
}
#keyframes obj-grow {
50% {
transform: scale(1);
}
}
<div class="nk-loader-c">
<div class="nk-loader-circle">
<div class="obj-circle"></div>
<div class="obj-circle"></div>
<div class="obj-circle"></div>
</div>
</div>
Can anyone help me with this? the rotation of the object circle is not
really 360degrees. Can anyone help me how can I make the rotation
360deg?
But when I tried using two circles the rotation if working on 360degress.
What about this?
.nk-loader-c {
padding-top: 50px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.nk-loader-circle {
position:absolute;
transform-origin: bottom center;
animation: obj-rotate 3s linear infinite;
height: 36px;
}
.obj-circle {
display: inline-block;
background-color: #6540eb;
height: 20px;
width: 20px;
border-radius: 50%;
transform: scale(0);
animation: obj-grow 1.5s linear infinite;
margin: -5px;
}
.nk-loader-circle:nth-child(1){
animation-delay: -0.5s;
}
.nk-loader-circle:nth-child(1) .obj-circle{
background-color: #3766f3;
animation-delay: 1.5s;
}
.nk-loader-circle:nth-child(2){
animation-delay: -.25s;
}
.nk-loader-circle:nth-child(2) .obj-circle{
background-color: #603aef;
animation-delay: .75s;
}
.nk-loader-circle:nth-child(3) {
animation-delay: 0s;
}
.nk-loader-circle:nth-child(3) .obj-circle{
background-color: #2998f6;
animation-delay: .37s;
}
#keyframes obj-rotate {
to {
transform: rotate(360deg);
}
}
#keyframes obj-grow {
50% {
transform: scale(1);
}
}
<div class="nk-loader-c">
<div class="nk-loader-circle">
<div class="obj-circle"></div>
</div>
<div class="nk-loader-circle">
<div class="obj-circle"></div>
</div>
<div class="nk-loader-circle">
<div class="obj-circle"></div>
</div>
</div>
</div>
I'm struggling to change the animation of my slider, every time I try to change something, the slider disappears. I want a slider right animation instead of fade.
I have researched, but nothing fits what I want.
.slider {
width: 100%;
height: 100vh;
position: relative;
overflow: hidden;
z-index: -1;
}
.slider .fadeimg {
width: 100%;
height: auto;
position: absolute;
top: 47.5%;
left: 50%;
transform: translate(-50%, -50%);
opacity: 0;
animation: galeria 9s infinite;
clip-path: ellipse(100% 95% at 50% 0%);
}
.fadeimg:nth-child(1) {}
.fadeimg:nth-child(2) {
animation-delay: 3s;
-webkit-animation-delay: 3s;
}
.fadeimg:nth-child(3) {
animation-delay: 6s;
-webkit-animation-delay: 6s;
}
#keyframes galeria {
33.33% {
opacity: 1;
}
100% {
opacity: 0;
}
}
<div class="slider">
<img class="fadeimg" src="img/dummy-640x310-1.jpg" alt="">
<img class="fadeimg" src="img/dummy-640x310-2.jpg" alt="">
<img class="fadeimg" src="img/dummy-640x310-3.jpg" alt="">
<div class="gradient"></div>
</div>
Try this:
.slider-container {
width:640px;
overflow:hidden;
}
.slider {
width: 2000px;
height: 100vh;
position: relative;
overflow: hidden;
z-index: -1;
}
.slider .fadeimg {
/*width: 100%;*/
width:auto;
height: auto;
/*position: absolute;
top: 47.5%;
left: 50%;
transform: translate(-50%, -50%);*/
opacity: 1;
animation: galeria 9s infinite;
clip-path: ellipse(100% 95% at 50% 0%);
}
.fadeimg:nth-child(1) {
animation-delay: 0s;
-webkit-animation-delay: 3s;
}
.fadeimg:nth-child(2) {
animation-delay: 3s;
-webkit-animation-delay: 3s;
}
.fadeimg:nth-child(3) {
animation-delay: 6s;
-webkit-animation-delay: 3s;
}
#keyframes galeria {
0% {
/*opacity: 1;*/
transform: translate(0%,0%);
}
50% {
transform: translate(-100%,0%);
}
100% {
transform: translate(-200%,0%);
}
}
<div class="slider-container">
<div class="slider">
<img class="fadeimg" src="https://dummyimage.com/640x310/0000ff/fff" alt="">
<img class="fadeimg" src="https://dummyimage.com/640x310/ff0000/fff" alt="">
<img class="fadeimg" src="https://dummyimage.com/640x310/00ff00/fff" alt="">
<div class="gradient"></div>
</div>
</div>
I am working on a project. I want to run some css property after 4000 ms. I want to run this only when javascript is disabled(if js is enabled, It will remove that class.).
How can I do this. Is it possible? If not any other solution?
Thanks for help in advance.
I didn't find any answer on web. So I tried last 3 days only for this and finally I got the solution. Here is the solution:
$(window).load(function() {
$(".loader").delay(3000).fadeOut(500, function() {
$(".main-cont").hide();
});
})
body {
margin: 0px;
padding: 0px;
background-color: #4CAF50;
color: #FFF;
font-family: arial;
font-size: 20px;
}
.main-cont {
background-color: #3F51B5;
width: 100vw;
height: 100vh;
display: inline-block;
padding-top: calc(50vh - 20px);
position: fixed;
text-align: center;
line-height: 20px;
opacity: 0;
-webkit-animation: css-delay 0ms infinite ease-in-out;
-moz-animation: css-delay 0ms infinite ease-in-out;
-ms-animation: css-delay 0ms infinite ease-in-out;
-o-animation: css-delay 0ms infinite ease-in-out;
-khtml-animation: css-delay 0ms infinite ease-in-out;
animation: css-delay 0ms infinite ease-in-out;
-webkit-animation-iteration-count: 1; /* Chrome, Safari, Opera */
animation-iteration-count: 1;
animation-delay : 10s; /* time for delay animation */
-webkit-animation-fill-mode: forwards;
animation-fill-mode: forwards;
}
.cont {
text-align: center;
display: block;
line-height: 20px;
padding-top: calc(50vh - 20px);
}
#keyframes css-delay {
0% {
opacity: 0;
display: none;
}
100% {
opacity: 1;
display: block;
}
}
/* this is only for loading animation */
.loader {
height: 100vh;
width: 100%;
display: inline-block;
/* display: none; */
position: fixed;
z-index: 0;
background-color: #333;
}
.sk-circle {
margin: 100px auto;
width: 40px;
height: 40px;
position: relative;
}
.sk-circle .sk-child {
width: 100%;
height: 100%;
position: absolute;
left: 0;
top: 0;
}
.sk-circle .sk-child:before {
content: '';
display: block;
margin: 0 auto;
width: 15%;
height: 15%;
background-color: #FFF;
border-radius: 100%;
-webkit-animation: sk-circleBounceDelay 1.2s infinite ease-in-out both;
animation: sk-circleBounceDelay 1.2s infinite ease-in-out both;
}
.sk-circle .sk-circle2 {
-webkit-transform: rotate(30deg);
-ms-transform: rotate(30deg);
transform: rotate(30deg); }
.sk-circle .sk-circle3 {
-webkit-transform: rotate(60deg);
-ms-transform: rotate(60deg);
transform: rotate(60deg); }
.sk-circle .sk-circle4 {
-webkit-transform: rotate(90deg);
-ms-transform: rotate(90deg);
transform: rotate(90deg); }
.sk-circle .sk-circle5 {
-webkit-transform: rotate(120deg);
-ms-transform: rotate(120deg);
transform: rotate(120deg); }
.sk-circle .sk-circle6 {
-webkit-transform: rotate(150deg);
-ms-transform: rotate(150deg);
transform: rotate(150deg); }
.sk-circle .sk-circle7 {
-webkit-transform: rotate(180deg);
-ms-transform: rotate(180deg);
transform: rotate(180deg); }
.sk-circle .sk-circle8 {
-webkit-transform: rotate(210deg);
-ms-transform: rotate(210deg);
transform: rotate(210deg); }
.sk-circle .sk-circle9 {
-webkit-transform: rotate(240deg);
-ms-transform: rotate(240deg);
transform: rotate(240deg); }
.sk-circle .sk-circle10 {
-webkit-transform: rotate(270deg);
-ms-transform: rotate(270deg);
transform: rotate(270deg); }
.sk-circle .sk-circle11 {
-webkit-transform: rotate(300deg);
-ms-transform: rotate(300deg);
transform: rotate(300deg); }
.sk-circle .sk-circle12 {
-webkit-transform: rotate(330deg);
-ms-transform: rotate(330deg);
transform: rotate(330deg); }
.sk-circle .sk-circle2:before {
-webkit-animation-delay: -1.1s;
animation-delay: -1.1s; }
.sk-circle .sk-circle3:before {
-webkit-animation-delay: -1s;
animation-delay: -1s; }
.sk-circle .sk-circle4:before {
-webkit-animation-delay: -0.9s;
animation-delay: -0.9s; }
.sk-circle .sk-circle5:before {
-webkit-animation-delay: -0.8s;
animation-delay: -0.8s; }
.sk-circle .sk-circle6:before {
-webkit-animation-delay: -0.7s;
animation-delay: -0.7s; }
.sk-circle .sk-circle7:before {
-webkit-animation-delay: -0.6s;
animation-delay: -0.6s; }
.sk-circle .sk-circle8:before {
-webkit-animation-delay: -0.5s;
animation-delay: -0.5s; }
.sk-circle .sk-circle9:before {
-webkit-animation-delay: -0.4s;
animation-delay: -0.4s; }
.sk-circle .sk-circle10:before {
-webkit-animation-delay: -0.3s;
animation-delay: -0.3s; }
.sk-circle .sk-circle11:before {
-webkit-animation-delay: -0.2s;
animation-delay: -0.2s; }
.sk-circle .sk-circle12:before {
-webkit-animation-delay: -0.1s;
animation-delay: -0.1s; }
#-webkit-keyframes sk-circleBounceDelay {
0%, 80%, 100% {
-webkit-transform: scale(0);
transform: scale(0);
} 40% {
-webkit-transform: scale(1);
transform: scale(1);
}
}
#keyframes sk-circleBounceDelay {
0%, 80%, 100% {
-webkit-transform: scale(0);
transform: scale(0);
} 40% {
-webkit-transform: scale(1);
transform: scale(1);
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<div class="loader">
<div class="sk-circle">
<div class="sk-circle1 sk-child"></div>
<div class="sk-circle2 sk-child"></div>
<div class="sk-circle3 sk-child"></div>
<div class="sk-circle4 sk-child"></div>
<div class="sk-circle5 sk-child"></div>
<div class="sk-circle6 sk-child"></div>
<div class="sk-circle7 sk-child"></div>
<div class="sk-circle8 sk-child"></div>
<div class="sk-circle9 sk-child"></div>
<div class="sk-circle10 sk-child"></div>
<div class="sk-circle11 sk-child"></div>
<div class="sk-circle12 sk-child"></div>
</div>
</div>
<div class="main-cont">
<a>please enable javascript on your browser.<br>
(uncomment out all js to see content.)
</a>
</div>
<div class="cont">
<a>all of youre contents.<br>
(just comment out all js to see result.)
</a>
</div>
I currently have 4 images and I use the CSS animation to reveal a different picture every X seconds. The problem is that I'd like to put an unique text for each image. For example, for the first image, "First Image", for the second, "Second Image", etc.
Here is my HTML code:
<div class="wrapper">
<div id="container">
<h1 id="all-available-styles">All available styles</h1>
<div id="all-available-styles-block">
<img src="images/test.jpg" alt="">
<img src="images/test2.jpg" alt="">
<img src="images/test3.jpg" alt="">
<img src="images/test4.jpg" alt="">
</div>
</div>
</div>
My CSS:
#welcome-to
{
text-align: center;
margin: 0 auto 15px auto;
width: 75%;
}
#all-available-styles
{
text-align: center;
margin-bottom: 25px;
}
#all-available-styles:before, #all-available-styles:after
{
content: "\f122";
display: inline-block;
position: relative;
top: 10px;
}
#all-available-styles:before
{
transform: rotate(250deg);
-webkit-transform: rotate(250deg);
-ms-transform: rotate(250deg);
-moz-transform: rotate(250deg);
margin-right: 5px;
}
#all-available-styles:after
{
margin-left: 5px;
transform: rotate(100deg) scaleX(-1);
-webkit-transform: rotate(100deg) scaleX(-1);
-ms-transform: rotate(100deg) scaleX(-1);
-moz-transform: rotate(100deg) scaleX(-1);
}
#all-available-styles-block
{
position: relative;
height: 281px;
}
#all-available-styles-block img
{
background-color: #FFFFFF;
margin: 0 auto;
padding: 2px;
position: absolute;
right: 0;
left: 0;
animation: allAvailableStylesBlockFadeInOut ease-in-out infinite 8s;
-webkit-animation: allAvailableStylesBlockFadeInOut ease-in-out infinite 8s;
box-shadow: rgba(0,0,0,0.3) 0px 1px 7px;
-webkit-box-shadow: rgba(0,0,0,0.3) 0px 1px 7px;
-moz-box-shadow: rgba(0,0,0,0.3) 0px 1px 7px;
width: 50%;
pointer-events: none;
}
#keyframes allAvailableStylesBlockFadeInOut
{
0%
{
opacity: 1;
}
17%
{
opacity: 1;
}
25%
{
opacity: 0;
}
92%
{
opacity: 0;
}
100%
{
opacity: 1;
}
}
#-webkit-keyframes allAvailableStylesBlockFadeInOut
{
0%
{
opacity: 1;
}
17%
{
opacity: 1;
}
25%
{
opacity: 0;
}
92%
{
opacity: 0;
}
100%
{
opacity: 1;
}
}
#-moz-keyframes allAvailableStylesBlockFadeInOut
{
0%
{
opacity: 1;
}
17%
{
opacity: 1;
}
25%
{
opacity: 0;
}
92%
{
opacity: 0;
}
100%
{
opacity: 1;
}
}
#-o-keyframes allAvailableStylesBlockFadeInOut
{
0%
{
opacity: 1;
}
17%
{
opacity: 1;
}
25%
{
opacity: 0;
}
92%
{
opacity: 0;
}
100%
{
opacity: 1;
}
}
#all-available-styles-block img:nth-of-type(1)
{
animation-delay: 6s;
-webkit-animation-delay: 6s;
-moz-animation-delay: 6s;
-o-animation-delay: 6s;
}
#all-available-styles-block img:nth-of-type(2)
{
animation-delay: 4s;
-webkit-animation-delay: 4s;
-moz-animation-delay: 4s;
-o-animation-delay: 4s;
}
#all-available-styles-block img:nth-of-type(3)
{
animation-delay: 2s;
-webkit-animation-delay: 2s;
-moz-animation-delay: 2s;
-o-animation-delay: 2s;
}
#all-available-styles-block img:nth-of-type(4)
{
animation-delay: 0;
-webkit-animation-delay: 0;
-moz-animation-delay: 0;
-o-animation-delay: 0;
}
Result: http://screencast.com/t/WPcf8X2b7z
So for each image, a text in the middle. I think I can do it with a :before or :after, but I did find the solution.
Thanks to people who will try to help me.
Check this:
http://jsfiddle.net/DariuszMusielak/qzrrqryd/
<div class="wrapper">
<div id="container">
<h1 id="all-available-styles">All available styles</h1>
<div id="all-available-styles-block">
<div class='image'>
<img src="http://marcisischo.com/wp-content/uploads/2014/12/TrollFace.png" alt="">
<p> nice troll face 1</p>
</div>
<div class='image'>
<img src="http://img4.wikia.nocookie.net/__cb20130116153004/uncyclopedia/images/c/cb/Internet-troll-face-explorer.png" alt="">
<p> nice troll face 2</p>
</div>
<div class='image'>
<img src="http://www.clipartbest.com/cliparts/dT6/MEb/dT6MEbgEc.gif" alt="">
<p> nice troll face 3</p>
</div>
<div class='image'>
<img src="http://fc02.deviantart.net/fs70/f/2011/074/f/f/kirby_troll_face_by_arashi93_sama-d3bqrxs.jpg" alt="">
<p> nice troll face 4</p>
</div>
</div>
</div>
</div>
Move images and text inside div, and add anima