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>
Related
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>
When I click the box and trigger this animation, it has a weird delay after the animation is played and before the top and bottom bar get to their desired end positions. I assume this is because of the transform-origin but not so sure. How can I make the animation to run smooth?
.box{
width: 200px; height: 200px;
background-color: #2C3E50;
float:left; margin: 20px;
}
.box label{
display: block;
width: 50px; margin: auto;
height: 50px;
transform: translateY(80px);
text-align: center;
}
.box span{
display: block;
width: 50px; height: 5px;
background-color: #fff;
margin-bottom: 10px;
border-radius: 5px;
}
input{display: none;}
input:checked+label span{ animation-play-state: running;}
#bars02:checked+label span{
animation-play-state: running;
transition: .5s;
}
#bars02:checked+label span:nth-child(1){
animation: rotatePlus .5s forwards;
transform-origin: left bottom;
}
#bars02+label span{
animation-play-state: paused;
}
#keyframes rotatePlus{
0%{ transform:rotate(0); }
100%{ transform: rotate(35deg); }
}
#bars02:checked+label span{
animation-play-state: running;
transition: .5s;
}
#bars02:checked+label span:nth-child(3){
transform-origin: left top;
animation: rotateMinus .5s forwards;
}
#bars02:checked+label span:nth-child(2){
animation: opacity .5s forwards;
}
#keyframes rotateMinus{
0%{ transform:rotate(0); }
100%{ transform: rotate(-35deg); }
}
<div class="box">
<input type="checkbox" id="bars02">
<label for="bars02">
<span></span>
<span></span>
<span></span>
</label>
</div>
It seems to be a Chrome bug. You can simplify your code like below and set the transform-origin initially
.box {
width: 200px;
height: 200px;
background-color: #2C3E50;
float: left;
margin: 20px;
}
.box label {
display: block;
width: 50px;
margin: auto;
height: 50px;
transform: translateY(80px);
text-align: center;
}
.box span {
display: block;
width: 50px;
height: 5px;
background-color: #fff;
margin-bottom: 10px;
border-radius: 5px;
transition: .5s;
}
input {
display: none;
}
label span:nth-child(1) {
transform-origin: left bottom;
}
label span:nth-child(3) {
transform-origin: left top;
}
#bars02:checked+label span:nth-child(1) {
transform: rotate(35deg);
transform-origin: left bottom;
}
#bars02:checked+label span:nth-child(3) {
transform-origin: left top;
transform: rotate(-35deg);
}
<div class="box">
<input type="checkbox" id="bars02">
<label for="bars02">
<span></span>
<span></span>
<span></span>
</label>
</div>
been working and learning to build this page for about 4-5 hours and I cannot seem to find out why I am unable to get the navigation links on the same line as the navbar-logo and secondly is there any way I could make this code more efficient and less dependent/error-prone?
One more thing I wanted to ask is can we use flexbox in this webpage? and is CSS animation used is efficient here?
body{
background-color: #000;
color: #f1f1f1;
animation: fade-in 2s 1;
}
header{
width: 100%;
height: 10%;
margin: auto;
}
.navbar-logo{
padding: 2px 0px 2px 100px;
position: absolute;
z-index: 100;
}
.navbar-logo-sub{
padding: 55px 0px 0px 200px;
}
#logo-main{
font-family: 'Didact Gothic', sans-serif;
color: white;
font-size: 40px;
font-weight: 800;
margin: 0;
}
.parenthesis1{
color: #b22121;
font-family: 'Bungee', cursive;
}
.parenthesis2{
color: #787878;
font-family: 'Bungee', cursive;
}
#logo-sub{
color: white;
font-size: 14px;
font-weight: 20;
font-family: 'Coming Soon', cursive;
}
#banner-image{
width: 50%;
padding-left: 20%;
filter: blur(3px);
position: relative;
padding-top: 5%;
}
#banner-text{
top: 50%;
left: 50%;
position: fixed;
transform: translate(-50%, -50%);
font-size: 50px;
text-align: left;
}
nav{
padding: 0px 0px 0px 60%;
}
li{
float: left;
margin-right: 100px;
list-style-type: none;
}
a{
text-decoration: none;
color: white;
}
h1{
margin-top: 0px;
margin-bottom: -50px;
font-family: 'Permanent Marker', cursive;
font-weight: 300;
text-shadow: 4px 2px rgba(238, 238, 238, 0.5);
opacity: 0;
-webkit-animation: slide-in 3s 1 forwards;
}
div h1:nth-of-type(2){
animation-delay: 0.1s;
-webkit-animation-delay: 0.1s;
}
div h1:nth-of-type(3){
animation-delay: 0.2s;
-webkit-animation-delay: 0.2s;
}
div h1:nth-of-type(4){
animation-delay: 0.3s;
-webkit-animation-delay: 0.3s;
}
div h1:nth-of-type(5){
animation-delay: 0.4s;
-webkit-animation-delay: 0.4s;
}
div h1:nth-of-type(6){
animation-delay: 0.5s;
-webkit-animation-delay: 0.5s;
}
div h1:nth-of-type(7){
animation-delay: 0.6s;
-webkit-animation-delay: 0.6s;
}
div h1:nth-of-type(8){
animation-delay: 0.7s;
-webkit-animation-delay: 0.7s;
}
div h1:nth-of-type(9){
animation-delay: 0.8s;
-webkit-animation-delay: 0.8s;
}
#keyframes slide-in {
0%{
transform: rotateY(90deg) translateY(-50%);
opacity: 0.0;
}
100%{
transform: rotateY(0deg) translateY(0%);
opacity: 1.0;
}
}
#-webkit-keyframes slide-in {
0%{
-webkit-transform: rotateY(90deg) translateY(25%);
opacity: 0.0;
}
100%{
-webkit-transform: rotateY(0deg) translateY(0%);
opacity: 1.0;
}
}
#keyframes fade-in {
0%{
opacity: 0.0;
}
50%{
opacity: 0.5;
}
100%{
opacity: 1.0;
}
<html>
<head>
<title>.whatsthecode.</title>
<link rel="stylesheet" href="index.css">
<link href="https://fonts.googleapis.com/css?
family=Didact+Gothic|Coming+Soon|Bungee|Permanent+Marker" rel="stylesheet">
</head>
<body>
<header>
<div class="navbar-logo">
<p id="logo-main">WhatsTheCode<span class="parenthesis1">(</span>
<span class="parenthesis2">)</span></p>
</div>
<div class="navbar-logo-sub"><p id="logo-sub">{<html><span style="color: #b22121"><style></span><span style="color: #787878"><script></span>}</p></div>
<nav>
<ul>
<li>Home</li>
<li>FAQ</li>
<li>About</li>
</ul>
</nav>
</header>
<section>
<div class="banner">
<img src="banner-background.png" id="banner-image">
<div id="banner-text"><h1>Your</h1><h1>web development</h1>
<h1>develops</h1><h1>here.</h1></div>
</div>
</section>
</body>
</html>
Here you go brother, I added a div with class="navbar-wrapper" and placed the header elements inside it. I used the display:inline-block on the header elements so that they are horizontally aligned. For the navbar-logo-sub, I placed it inside the navbar-logo and used position:absolute, and bottom:0 to place it at the bottom of the parent element. Run Code snippet and view it on full page.
body {
background-color: #000;
color: #f1f1f1;
animation: fade-in 2s 1;
}
header {
width: 100%;
}
.navbar-wrapper{
padding-left:50px; padding-right:50px;
}
header .navbar-logo {
display: inline-block;
position: relative;
}
header nav {
display: inline-block;
}
header .navbar-logo-sub {
display: block;
position: absolute;
bottom: 0;
left: 20%;
}
nav {
padding: 0px;
margin: 0px;
}
header li {
float: left;
margin-right: 50px;
list-style-type: none;
}
header li:last-of-type {
margin-right: 0px;
}
a {
text-decoration: none;
color: white;
}
#logo-main {
font-family: 'Didact Gothic', sans-serif;
color: white;
font-size: 2.3em;
font-weight: 800;
margin: 0;
}
.parenthesis1 {
color: #b22121;
font-family: 'Bungee', cursive;
}
.parenthesis2 {
color: #787878;
font-family: 'Bungee', cursive;
}
#logo-sub {
color: white;
font-size: 14px;
font-weight: 20;
font-family: 'Coming Soon', cursive;
}
#banner-image {
width: 50%;
padding-left: 20%;
filter: blur(3px);
position: relative;
padding-top: 5%;
}
#banner-text {
top: 50%;
left: 50%;
position: fixed;
transform: translate(-50%, -50%);
font-size: 50px;
text-align: left;
}
h1 {
margin-top: 0px;
margin-bottom: -50px;
font-family: 'Permanent Marker', cursive;
font-weight: 300;
text-shadow: 4px 2px rgba(238, 238, 238, 0.5);
opacity: 0;
-webkit-animation: slide-in 3s 1 forwards;
}
div h1:nth-of-type(2) {
animation-delay: 0.1s;
-webkit-animation-delay: 0.1s;
}
div h1:nth-of-type(3) {
animation-delay: 0.2s;
-webkit-animation-delay: 0.2s;
}
div h1:nth-of-type(4) {
animation-delay: 0.3s;
-webkit-animation-delay: 0.3s;
}
div h1:nth-of-type(5) {
animation-delay: 0.4s;
-webkit-animation-delay: 0.4s;
}
div h1:nth-of-type(6) {
animation-delay: 0.5s;
-webkit-animation-delay: 0.5s;
}
div h1:nth-of-type(7) {
animation-delay: 0.6s;
-webkit-animation-delay: 0.6s;
}
div h1:nth-of-type(8) {
animation-delay: 0.7s;
-webkit-animation-delay: 0.7s;
}
div h1:nth-of-type(9) {
animation-delay: 0.8s;
-webkit-animation-delay: 0.8s;
}
#keyframes slide-in {
0% {
transform: rotateY(90deg) translateY(-50%);
opacity: 0.0;
}
100% {
transform: rotateY(0deg) translateY(0%);
opacity: 1.0;
}
}
#-webkit-keyframes slide-in {
0% {
-webkit-transform: rotateY(90deg) translateY(25%);
opacity: 0.0;
}
100% {
-webkit-transform: rotateY(0deg) translateY(0%);
opacity: 1.0;
}
}
#keyframes fade-in {
0% {
opacity: 0.0;
}
50% {
opacity: 0.5;
}
100% {
opacity: 1.0;
}
<html>
<head>
<title>.whatsthecode.</title>
<link href="https://fonts.googleapis.com/css?
family=Didact+Gothic|Coming+Soon|Bungee|Permanent+Marker" rel="stylesheet">
</head>
<body>
<header>
<div class="navbar-wrapper">
<div class="navbar-logo">
<p id="logo-main">WhatsTheCode<span class="parenthesis1">(</span>
<span class="parenthesis2">)</span></p>
<div class="navbar-logo-sub">
<p id="logo-sub">{<html><span style="color: #b22121"><style></span><span style="color:
#787878"><script></span>}</p>
</div>
</div>
<nav>
<ul>
<li>Home</li>
<li>FAQ</li>
<li>About</li>
</ul>
</nav>
</div>
</header>
<section>
<div class="banner">
<img src="banner-background.png" id="banner-image">
<div id="banner-text">
<h1>Your</h1>
<h1>web development</h1>
<h1>develops</h1>
<h1>here.</h1>
</div>
</div>
</section>
</body>
</html>
How can I adjust the width of how long the <hr class="content-divider"> is but I need it to be responsive. I don't want the line to go past from where the buttons on each side end.
My site code.
Here is the html to the line divider.
<hr class="content-divider">
Update css part
.content-divider {
border-top: 1px solid #f8f8f8;
border-bottom: 1px solid rgba(0,0,0,0.2);
position:relative; /*Add this*/
left:0px; /*Add this*/
right:0px; /*Add this*/
margin: 20px auto; /*Add this you can change as your need*/
max-width:70%; /*Add this*/
}
Working fiddle - fiddle link
body {
background-color: #1b1b1b;
}
#app {
display: none;
}
#splash {
margin: 200px auto;
}
#splash span {
width: 16px;
height: 16px;
border-radius: 50%;
display: inline-block;
position: absolute;
left: 50%;
margin-left: -10px;
-webkit-animation: 3s infinite linear;
-moz-animation: 3s infinite linear;
-o-animation: 3s infinite linear;
}
#splash span:nth-child(2) {
background: white;
-webkit-animation: kiri 1.2s infinite linear;
-moz-animation: kiri 1.2s infinite linear;
-o-animation: kiri 1.2s infinite linear;
}
#splash span:nth-child(3) {
background: white;
z-index: 100;
}
#splash span:nth-child(4) {
background: white;
-webkit-animation: kanan 1.2s infinite linear;
-moz-animation: kanan 1.2s infinite linear;
-o-animation: kanan 1.2s infinite linear;
}
#-webkit-keyframes kanan {
0% {
-webkit-transform: translateX(20px);
}
50% {
-webkit-transform: translateX(-20px);
}
100% {
-webkit-transform: translateX(20px);
z-index: 200;
}
}
#-moz-keyframes kanan {
0% {
-moz-transform: translateX(20px);
}
50% {
-moz-transform: translateX(-20px);
}
100% {
-moz-transform: translateX(20px);
z-index: 200;
}
}
#-o-keyframes kanan {
0% {
-o-transform: translateX(20px);
}
50% {
-o-transform: translateX(-20px);
}
100% {
-o-transform: translateX(20px);
z-index: 200;
}
}
#-webkit-keyframes kiri {
0% {
-webkit-transform: translateX(-20px);
z-index: 200;
}
50% {
-webkit-transform: translateX(20px);
}
100% {
-webkit-transform: translateX(-20px);
}
}
#-moz-keyframes kiri {
0% {
-moz-transform: translateX(-20px);
z-index: 200;
}
50% {
-moz-transform: translateX(20px);
}
100% {
-moz-transform: translateX(-20px);
}
}
#-o-keyframes kiri {
0% {
-o-transform: translateX(-20px);
z-index: 200;
}
50% {
-o-transform: translateX(20px);
}
100% {
-o-transform: translateX(-20px);
}
}
.n2j-loading-video {
width: 60px;
height: 60px;
margin: auto;
border-color: white transparent white transparent;
border-width: 5px;
border-style: solid;
animation: loading 1s ease infinite;
position: fixed;
border-radius: 50%;
z-index: 1;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
#keyframes loading {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
body,
html {
width: 100%;
height: 100%;
}
.header1 {
text-align: center;
color: #f8f8f8;
}
.header-content>h1 {
font-size: 5rem;
font-family: sans-serif;
font-weight: 700;
margin: 0;
}
.header-content>h3 {
font-size: 3rem;
font-family: sans-serif;
font-weight: 400;
margin: 0;
}
.header-content {
position: relative;
padding-top: 20%;
padding-bottom: 20%;
}
.content-divider {
border-top: 1px solid #f8f8f8;
border-bottom: 1px solid rgba(0, 0, 0, 0.2);
position: relative;
left: 0px;
right: 0px;
margin: 20px auto;
max-width: 70%;
}
.btn.outline {
background: none;
padding: 12px 22px;
}
.btn-primary.outline {
border: 2px solid #f8f8f8;
color: #f8f8f8;
}
.btn-primary.outline:hover,
.btn-primary.outline:focus,
.btn-primary.outline:active,
.btn-primary.outline.active,
.open>.dropdown-toggle.btn-primary {
color: #f7ca18;
border-color: #f7ca18;
}
.btn-primary.outline:active,
.btn-primary.outline.active {
border-color: #f7ca18;
color: #f7ca18;
box-shadow: none;
}
ul.intro-social-buttons li {
padding-bottom: 10px;
}
<script>
setTimeout(function() {
document.getElementById('app').style['display'] = 'block';
document.getElementById('splash').style['display'] = 'none';
}, 3000);
</script>
<!--The script above is placed in head within my code-->
<body>
<div id="splash">
<div class='n2j-loading-video'></div>
</div>
<div id="app">
<div class="header1">
<div class="container">
<div class="row">
<div class="col-lg-12">
<div class="header-content">
<h1 class="maintxt rotateInUpLeft animated">LIAM DOCHERTY</h1>
<h3 class="subtxt rotateInUpLeft animated">WEB DEVELOPER & GRAPHIC DESIGNER</h3>
<hr class="content-divider">
<ul class="list-inline intro-social-buttons">
<li>
<i class="fa fa-linkedin fa-fw"></i> <span class="network-name">Web Development Portfolio</span>
</li>
<li>
<i class="fa fa-linkedin fa-fw"></i> <span class="network-name">GFX Design Portfolio</span>
</li>
<li>
<i class="fa fa-linkedin fa-fw"></i> <span class="network-name">About Me</span>
</li>
<li>
<i class="fa fa-linkedin fa-fw"></i> <span class="network-name">Contact Me</span>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<!-- /.container -->
</div>
<!-- /.intro-header -->
<script src="js/javascript.js"></script>
</body>
</html>
I want to make center this Miss, hug...
This is my site: https://www.ajdinalic.cf/
Image: http://prntscr.com/69oewr
I am still new at this coding, and found this code on google
This is on weebly btw, i tried to fix but i dont know and i dont want to make it worse
.rw-wrapper{
width: 80%;
position: relative;
margin: 110px auto 0 auto;
font-family: 'Bree Serif';
padding: 10px;
}
.rw-sentence{
margin: 0;
text-align: center;
text-shadow: 1px 1px 1px rgba(255,255,255,0.8);
}
.rw-sentence span{
color: #444;
white-space: initial;
font-size: 200%;
font-weight: normal;
}
.rw-words{
display: inline;
}
.rw-words span{
position: absolute;
opacity: 0;
overflow: hidden;
width: 100%;
color: #6b969d;
text-align: center;
}
.rw-words-1 span{
animation: rotateWordsFirst 18s linear infinite 0s;
text-align: center;
}
.rw-words-2 span{
animation: rotateWordsSecond 18s linear infinite 0s;
}
.rw-words span:nth-child(2) {
animation-delay: 3s;
color: #6b889d;
}
.rw-words span:nth-child(3) {
animation-delay: 6s;
color: #6b739d;
}
.rw-words span:nth-child(4) {
animation-delay: 9s;
color: #7a6b9d;
}
.rw-words span:nth-child(5) {
animation-delay: 12s;
color: #8d6b9d;
}
.rw-words span:nth-child(6) {
animation-delay: 15s;
color: #9b6b9d;
}
#keyframes rotateWordsFirst {
0% { opacity: 1; animation-timing-function: ease-in; height: 0px; }
8% { opacity: 1; height: 60px; }
19% { opacity: 1; height: 60px; }
25% { opacity: 0; height: 60px; }
100% { opacity: 0; }
}
#keyframes rotateWordsSecond {
0% { opacity: 1; animation-timing-function: ease-in; width: 0px; }
10% { opacity: 0.3; width: 0px; }
20% { opacity: 1; width: 100%; }
27% { opacity: 0; width: 100%; }
100% { opacity: 0; }
}
<!DOCTYPE html>
<html>
<head></head>
<section class="rw-wrapper">
<h2 class="rw-sentence">
<span>I</span>
<br>
<div class="rw-words rw-words-1">
<span>Miss</span>
<span>Want to hug</span>
<span>Want to kiss</span>
<span>Need</span>
<span>Want to see</span>
<span>Want to be with</span>
</div><br>
<span>You</span>
</h2>
</section>
<body class=' wsite-theme-light'>
<div style='display:none'>{title}</div>
<div style='display:none'>{menu}</div>
<div style='display:none'>{content}</div>
<div style='display:none'>{content}>{footer}</div>
</body>
</html>
Add top: 75px; left: 0; right: 0; to .rw-words span.
Let me know if this helps.